I'm converting binary data in two programs. Had everything working OK until I found that all the binary data needs to be in Big endian byte order. So...
Situation 1: the input data is Intel standard IEEE reals. I need to output same as BIG endian IEEE reals
Situation 2: the input data is 16bit signed integer output directly from a high precision low distortion A/D. The data is 16channel multiplexed data. I read in, convert to single, apply gain, amplify and demux to an IEEE real array. Then I need to output as BIG endian IEEE reals.
In both cases I also have two binary buffers of 16bit and 32 bit integers that will need to be output as BIG endian. I think I can just use swap() on these buffers and be OK.
Can I use the following routine (found on the web) for the reals to convert to big endian?
function EndianLong(L : longint) : longint;
begin
result := swap(L shr 6) or
(longint(swap(L and $ffff)) shl 6);
end;
"EndianLong" was designed for 4 byte integers but will my IEEE exponent survive if I use this one or is there a big endian routine specifically for reals?
Thanks
Bob
Situation 1: the input data is Intel standard IEEE reals. I need to output same as BIG endian IEEE reals
Situation 2: the input data is 16bit signed integer output directly from a high precision low distortion A/D. The data is 16channel multiplexed data. I read in, convert to single, apply gain, amplify and demux to an IEEE real array. Then I need to output as BIG endian IEEE reals.
In both cases I also have two binary buffers of 16bit and 32 bit integers that will need to be output as BIG endian. I think I can just use swap() on these buffers and be OK.
Can I use the following routine (found on the web) for the reals to convert to big endian?
function EndianLong(L : longint) : longint;
begin
result := swap(L shr 6) or
(longint(swap(L and $ffff)) shl 6);
end;
"EndianLong" was designed for 4 byte integers but will my IEEE exponent survive if I use this one or is there a big endian routine specifically for reals?
Thanks
Bob