Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


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

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

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

I have to extract float numbers from raw .btf file.
Each number occupies 6 bytes. Do you know how does Btrieve
save float numbers?

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

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.

Custom VB and Btrieve development.
Certified Pervasive Developer
Certified Pervasive Technician

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

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?

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

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.

Custom VB and Btrieve development.
Certified Pervasive Developer
Certified Pervasive Technician

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

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 www.nssdd.com.  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.


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

These are 6-byte floats. See below...
Goldstar Software Inc.
Building on Btrieve(R) for the Future(SM)
Bill Bach
*** 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?

The old Turbo Pascal "Real" type is a 6-byte floating point quantity. The format is
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;


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close