Re: Binary file byte ordering
groufosse@xxxxxxx wrote:
1 - How are the bytes ordered when they are read in? This is critical
because I am reading
in a byte at a time (as U8)
2 - What is the ordering of the bytes....The endian-ness?
On x86 processors, it will be lowest byte first. Just do something like
this:
type
ConvertRec = packed record
case Boolean of
False: (Bytes: array[0..9] of Byte);
True: (Value: Extended);
end;
...
for I := 0 to 9 do
begin
ReadNextByteInto(X);
MyRec.Bytes[I] := X;
end;
Value := MyRec.Value;
Of course, if you could read more than one byte at once, it would be a
lot easier. Assuming Value is an Extended, and you were reading from a
stream, you could do:
Stream.Read(Value, Sizeof(Value));
--
Rudy Velthuis
http://rvelthuis.de
"Maybe this world is another planet's Hell."
-- Aldous Huxley (1894-1963)
.
Relevant Pages
- Re: Would You call the new CD Generic?
... Hell, after reading his wide-eyed wonder with the marvels of a modern ... But, hell, he could be singing about the latest ... But just as portions of JOAD came about as result of reading an L.A. TIMES ... between the Phil Ochs approach (where Ochs seemed to lift his songs based on ... (rec.music.artists.springsteen) - Re: Day Two
... "Hell Week" is rougher than a cob on everyone. ... pete wrote in message ... some nervous energy then came in and ate a steak. ... Reading about them from what you guys have ... (alt.support.stop-smoking) - OFF TOPIC (Youve Been Warned!) Finally the End to the Religious Confusion
... "Faith Converter" is available for the Mac. ... send you to Hell, with Satan, for not reading your Bible." ... through dharma will send you to hell, with Mao, for not reading your ... (sci.med.cardiology) - Re: Im on the edge.
... and have realised what Rowland said was true. ... Since my first post the other day (and after reading Rowlands comments) I have cut my Mirtazapine RIGHT down to a single 15mg at night, ... It is very odd to say the least, I feel as shaky as hell like I said, shaky as hell, trembling, sweating,dizzy, but you know what, I feel "alive" again, Even after just two days!- I'm going to give him hell tomorrow when I go to see him 17 bloody years he has had me in this state. ... It got to the stage I thought that it was me, my depression, but obviously, by the way I feel writing this, it was the meds. ... (uk.people.support.depression) - Re: Cohens paper on byte order
... Paul Schlyter wrote: ... If one doesn't assume an implicitly given endian-ness ... to interpret a digit sequence as a whole number. ... Direction of reading has nothing to ... (sci.crypt) |
|