Ivankooo1

HEX

Oct 8th, 2020
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. class Hex{
  2. constructor(value){
  3. this.value = value;
  4. }
  5.  
  6. toString(){
  7. return "0x" + this.value.toString(16).toUpperCase();
  8. }
  9.  
  10. valueOf(){
  11. return this.value;
  12. }
  13.  
  14. plus(hex){
  15. return new Hex(this.value + hex);
  16. }
  17.  
  18. minus(hex){
  19. return new Hex(this.value - hex);
  20. }
  21.  
  22. static parse(hex){
  23. return parseInt(hex,16);
  24. }
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment