Hi,
I'm afraid it's not quite that simple. Here's an example...
24h = 86400 seconds
Code:
86400 in binary:
00000000 00000001 01010001 10000000
If you actually rotate each byte (ie the LSB gets moved to MSB) individually the result becomes:
Code:
00000000 10000000 10101000 01000000
Which in decimal is: 8431680 seconds or 2352h
If you instead of rotate simply shift each byte individually (or divide each byte by 2 individually) the result becomes:
Code:
00000000 00000000 00101000 01000000
Which in decimal would be 10304 seconds or 2.9h
As you can see neither of the above results is the expected 43200 seconds or 12h.
You need to make sure that the LSB of each significant byte get moved into the MSB of the less significant byte so that result with the above numbers becomes:
Code:
00000000 00000000 10101000 11000000
Which in decimal is: 43200 seconds or 12h
/Henrik.
Bookmarks