Re: Hexadecimal and whatever...
- Posted by Architek <architek at GEOCITIES.COM> Apr 15, 1997
- 914 views
James Powell wrote: > The problem is that 1 byte (8 bits) will hold 2^8 (256) values, ie &H00-&HFF. > If you combine 4 bytes (32 bits, and your basic integer type) you can now stor e > 2^32 (4,294,967,292) values, or &H00-&HFFFFFFFF. > You want the hex value &H06 (00000006). Since that is less than &HFF, it is > stored in a SINGLE byte, rather than a 4 byte integer. When you combine the > four > bytes that you are reading, it makes a much larger value (10105342) than you > wanted. Maybe you could say that H06 could be stored in ANY amount of byte... example: In 4 bytes: #00, #00, #06 In 2 bytes: #00, #06 .. etc... In general you can say that the value of a number stored in several bytes is: (byte1)+(byte2*256)+(byte3*256^2)+(byte4*256^3)+ ... +(byteN*256^N-1) where byte1 is the least significant byte and byte N the most significant byte. In the above examples: (6)+(0*256)+(0*65536) = 6 > Anyway, just use each byte seperately rather than making an integer out of 4 > of them. James is right... the number you've got 101053452 is in hexadecimal 06 05 F4 0C which i interpret as been the right result for you to get EACH BYTE alone and not trying to get 4 byte numbers (4 byte number = 2^32). Hope this helps you, if you need more info about binary numbers just ask me, som e time ago I had the same troubles trying to understand how numbers where stored ; ) Bye, -- ************************************ This message sent by Daniel Berstein ************************************ email: architek at geocities.com homepages: http://www.geocities.com/SiliconValley/Heights/9316 http://www.cybercity.hko.net/silicon_valley/architek