Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

float number's format in .btf (Btrieve/N ver.5.00a)

Status
Not open for further replies.

pwozniak5

Programmer
Jun 18, 2004
9
PL
Hi,
I have to extract float numbers from raw .btf file.
Each number occupies 6 bytes. Do you know how does Btrieve
save float numbers?
Piotr
 
Btrieve saves data exactly as it's sent to Btrieve to be stored. If this field has an index, you can see what the developer had in mind in terms of data type.


info@mirtheil.com
Custom VB and Btrieve development.
Certified Pervasive Developer
Certified Pervasive Technician
 
I'm not familiar with Btrieve..
I try to describe the problem more exactly.
I know that, for example, the number 0.5
is saved as chain of six bytes: 80|00|00|00|00|00 (hex),
number 1.5 as 81|00|00|00|00|40,
2.0 as 82|00|00|00|00|00.
Do you know how were they encoded?
Piotr

 
I have not seen that type of encoding. Your best option would be to go to the vendor of the application and ask them what the encoding is. Failing that, you could also look in the application source code to find the encoding.
Remember, the application is encoding the data, not Btrieve/Pervasive.


info@mirtheil.com
Custom VB and Btrieve development.
Certified Pervasive Developer
Certified Pervasive Technician
 
Btrieve saves numbers, dates and times in binary format. The developer can use one of the standard Btrieve data types or since Btrieve can contain any type of data they can also use non-standard binary types. If you need to try and analzye the structure you can take a look at BtSearch at It helps you analyze the btrieve structure and creates the DDF files. It supports the Btrieve binary types as well as some of the other common ones used in Btrieve files.



Gil
 
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);
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top