Guest User

Untitled

a guest
May 25th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. let dec = process.argv[2];
  2. let result = '';
  3.  
  4. const getChar = char =>
  5. ({
  6. '10': 'A',
  7. '11': 'B',
  8. '12': 'C',
  9. '13': 'D',
  10. '14': 'E',
  11. '15': 'F'
  12. }[char] || char);
  13.  
  14. do {
  15. const float = dec / 16;
  16. const int = (dec = Math.floor(float));
  17. const remainder = (float - int) * 16;
  18.  
  19. result = getChar(remainder) + result;
  20. } while (dec !== 0);
  21.  
  22. console.log(result);
Add Comment
Please, Sign In to add comment