Re: Hexadecimal and whatever...
On Tue, 15 Apr 1997 20:09:36 -0400 Jacques Deschenes
<desja at QUEBECTEL.COM> writes:
>At 16:57 97-04-15 -0400, you wrote:
>
>>Okay. I get this BRILLIANT idea and decide to star reading bytes from
>files.
>>I need to make it a number, so I use bytes_to_int to change a set of
>four
>bytes.
>>Truth is, I'm seeing if I can read data in from a MIDI file (don't
>ask me
>>why), and I read in the integer 101053452 (well, not exactly), but
>I'm
>>supposed to get the hexadecimal 00000006. Anyways, I think the
>problem is
>>that I need to read the bytes directly into hexadecimal. Anyone know
>how to
>>do that?
>>
>>P.S. Anyone know what I'm talking about?
>>
>
>1) In MIDI file integer are stored in straigth order as opposed to the
>inverted order used in PC. bytes_to_int() suppose that the first byte
>is the
>least significant (INTEL style) in MIDI file the first byte is most
>significant (MOTOROLA style), so bytes_to_int() will give a wrong
>result if
>you use it to read MIDI file.
>
>Jacques Deschenes
>Baie-Comeau, Quebec
>Canada
>desja at quebectel.com
>
Jacques is right. :)
You should get help reading binary numbers.
To do this will require loading each number say a 2 byte number
1 byte at a time
the first byte, or byte1, is value
and the second byte, or byte2, is value*256
so the number is first+(second*256) OR
number = byte1 + (byte2 * 256)
NOTE: Paranthesis not needed.
DON'T take my word for it though. Somebody check this for me.
I am a bit busy lately.
HOPE this helps.
--Lucius Lamar Hilley III
-- E-mail at luciuslhilleyiii at juno.com
-- I support transferring of files less than 60K.
-- I can Decode both UU and Base64 format.
|
Not Categorized, Please Help
|
|