These are 6-byte floats. See below...
Goldstar Software Inc.
Building on Btrieve(R) for the Future(SM)
Bill Bach
BillBach@goldstarsoftware.com
*** Pervasive.SQL Service & Support Classes ***
Chicago: August, 2004: See our web site for details!
APP - Accessing 6-Byte Floating Point Values
Application: Any Old App
Version: PSQL2000
Issue: (NG)
I've got an application which uses an old Pascal Data type which is a 6-byte float. Any ideas how this information is stored?
Resolution:
The old Turbo Pascal "Real" type is a 6-byte floating point quantity. The format is
MSB LSB
SFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF EEEEEEEE
S : sign
F : mantissa (implicit leading "1" bit)
E : exponent
if 0 < E <= 255 then Value = (-1)^S * 2^(E -129) * (1.F)
if E = 0 then Value = 0
[From Doug Reilly]
I have some C source (below) that I think will interpret it if this is for TrustMark data files.
They used some old Turbo Pascal, I think. I worked with Nations Bank on this some time ago, and my BTVIEWER actually supports that type, using the old Smithware code for 6 byte float.
typedef unsigned char pasreal[6];
typedef unsigned char bassngl[4];
typedef unsigned char basdble[8];
typedef union {
double value;
unsigned char byte[8];
} IEEEdouble;
double pasrealtodouble(pasreal OldNum);
double bassngltodouble(bassngl OldNum);
double basdbletodouble(basdble OldNum);
void doubletopasreal(pasreal *New, double Old);
void doubletobassngl(bassngl *New, double Old);
void doubletobasdble(basdble *New, double Old);
/* converts TP 6-byte real to IEEE 8-byte real */
double pasrealtodouble(pasreal OldNum) {
IEEEdouble NewNum;
char Sign;
int Exp;
int X;
for(X = 0; X < 2; X++)
NewNum.byte[X] = 0x00;
Sign = OldNum[5] & 0x80;
Exp = OldNum[0] - 0x81 + 0x3FF;
NewNum.byte[6] = (Exp << 4);
NewNum.byte[7] = (Exp >> 4) | Sign;
for(X = 5; X > 1; X--) {
OldNum[X] <<= 1;
OldNum[X] |= OldNum[X-1] >> 7;
}
OldNum[1] <<= 1;
for(X = 6; X >= 2; X--) {
NewNum.byte[X] |= OldNum[X-1] >> 4;
NewNum.byte[X-1] = OldNum[X-1] << 4;
}
return(NewNum.value);
}