Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- I did for 32 bit you can do the same for 64 bit
- 255 247 247 is 1111 1111 1111 0111 1111 0111
- now you have stored them in big variables like
- byte 1 0000 0000 0000 0000 0000 0000 1111 1111
- byte 2 0000 0000 0000 0000 0000 0000 1111 0111
- byte 3 0000 0000 0000 0000 0000 0000 1111 0111
- if Byte1 AND 0x00000080
- then negate and you get
- byte 1 1111 1111 1111 1111 1111 1111 0000 0000
- byte 2 1111 1111 1111 1111 1111 1111 0000 1000
- byte 3 1111 1111 1111 1111 1111 1111 0000 1000
- Add One to LSB
- byte 1 1111 1111 1111 1111 1111 1111 0000 0000
- byte 2 1111 1111 1111 1111 1111 1111 0000 1000
- byte 3 1111 1111 1111 1111 1111 1111 0000 1001
- make sure we do not have overflow
- if(Byte3 AND 0x100)
- byte2 + 1
- if(Byte2 AND 0x100)
- byte3 + 1
- now use AND 0xFF and you get
- byte 1 0000 0000 0000 0000 0000 0000 0000 0000
- byte 2 0000 0000 0000 0000 0000 0000 0000 1000
- byte 3 0000 0000 0000 0000 0000 0000 0000 1001
- now shift (Byte1 << 16 OR Byte 2 <<8 OR Byte 3)
- you get 0000 0000 0000 0000 0000 0000 1000 1001
- decimal 137
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement