Advertisement
Guest User

Untitled

a guest
May 26th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. I did for 32 bit you can do the same for 64 bit
  2.  
  3. 255 247 247 is 1111 1111 1111 0111 1111 0111
  4. now you have stored them in big variables like
  5. byte 1 0000 0000 0000 0000 0000 0000 1111 1111
  6. byte 2 0000 0000 0000 0000 0000 0000 1111 0111
  7. byte 3 0000 0000 0000 0000 0000 0000 1111 0111
  8.  
  9. if Byte1 AND 0x00000080
  10. then negate and you get
  11.  
  12. byte 1 1111 1111 1111 1111 1111 1111 0000 0000
  13. byte 2 1111 1111 1111 1111 1111 1111 0000 1000
  14. byte 3 1111 1111 1111 1111 1111 1111 0000 1000
  15.  
  16. Add One to LSB
  17. byte 1 1111 1111 1111 1111 1111 1111 0000 0000
  18. byte 2 1111 1111 1111 1111 1111 1111 0000 1000
  19. byte 3 1111 1111 1111 1111 1111 1111 0000 1001
  20.  
  21. make sure we do not have overflow
  22. if(Byte3 AND 0x100)
  23. byte2 + 1
  24. if(Byte2 AND 0x100)
  25. byte3 + 1
  26.  
  27. now use AND 0xFF and you get
  28.  
  29. byte 1 0000 0000 0000 0000 0000 0000 0000 0000
  30. byte 2 0000 0000 0000 0000 0000 0000 0000 1000
  31. byte 3 0000 0000 0000 0000 0000 0000 0000 1001
  32.  
  33. now shift (Byte1 << 16 OR Byte 2 <<8 OR Byte 3)
  34.  
  35. you get 0000 0000 0000 0000 0000 0000 1000 1001
  36.  
  37. decimal 137
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement