Many examples can be found to demonstrate how to convert the Turbo Pascal 6 byte Real into IEEE compliant floating point types WITHIN a PASCAL environment.
I need to write routines in ANSI C that can read/write these reals from/to a binary file when they are part of variant record type. I am concerned that I must also consider word/byte ordering as well as the internal representation of the exponent and mantissa.
Has anybody seen and/or does anybody have source code for doing this in ANSI C?
If not, can anybody enlighten me as to exactly how the following record should be written to a binary file, particularly the Reals?
Record_Type = (Header_Block, Data_Block);
Data_Record = record case Header_Trailer : Record_Type of Header_Block : ( {variant type 1}
NumChan : Integer; {16}
Gain : Integer; {0}
Freq : Real; {100.0}
SampT : Real; {10.0}
Ymin : array[0..15] of Real; {0.0}
Ymax : array[0..15] of Real; {4095.0}
Slope : array[0..15] of Real; {1.0}
Intercept : array[0..15] of Real; {0.0}
Data_time : LongInt;
);
Data_Block : ({variant type 2}
DataLine : array[0..4095] of Integer; {0-4095 or -9999}
);
end; {record case}Trevor Cooper
UCSD Division of Physiology
