On 2/16/07, Rubber Chicken Software Co. <[EMAIL PROTECTED]> wrote:
At 09:03 AM 1/19/2007, you wrote:
So, 1) find out what endian the binary data is, then 2) use your own
functions to read the data. I use the following self-written functions:
GetFourIntel(memoryblock, location)
GetFourMotorola(memoryblock, location)
GetFourAny(memoryblock, location, byteorder) // which routes to the
above two functions
GetTwoIntel(memoryblock, location)
GetTwoMotorola(memoryblock, location)
GetTwoAny(memoryblock, location, byteorder) // which routes to the
above two functions
... etc. etc. for Float and Double and 24-bit numbers, etc.
These function effectively wrap the #if TargetX86 conditional
declares necessary to read things properly regardless of platform.
Your code shouldn't be littered with #ifdefs, which is what happens
if you choose the .LittleEndian() method approach on a "case-by-case" basis.
I like this approach because my code becomes self-documenting.
Hi Garth:
This sounds very sensible. I thought of doing it even more simply,
and that is to explicitly force all memblocks to be littleEndian =
false (PPC/Motorola-style), regardless of platform. My only concern
is: is there a performance hit on Intel when the memblocks are read in
a non-native (PPC) byte-order?
Peter.
--
-------------------------------------------------------------------------------
Peter K. Stys, MD
Professor of Medicine(Neurology), Senior Scientist
Ottawa Health Research Institute, Div. of Neuroscience
Ottawa Hospital / University of Ottawa
Ontario, CANADA
tel: (613)761-5444
fax: (613)761-5330
http://www.ohri.ca/profiles/stys.asp
-------------------------------------------------------------------------------
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>