Jump to content

Need help with float converting/formatting


jwurmz
 Share

Recommended Posts

I have some 32bit numbers stored in a particular format (used in a QBASIC 7.1 program) and I can't seem to figure out how to display them properly after reading them in using FileRead (FileOpened with "0" flag).

Here's an example:

0x99996183, displayed in the QBASIC7.1 app as "7.05"

Can anyone provide suggestion on how to convert/format these raw 32bit numbers into their readable, decimal counterpart?

Link to comment
Share on other sites

I have some 32bit numbers stored in a particular format (used in a QBASIC 7.1 program) and I can't seem to figure out how to display them properly after reading them in using FileRead (FileOpened with "0" flag).

Here's an example:

0x99996183, displayed in the QBASIC7.1 app as "7.05"

Can anyone provide suggestion on how to convert/format these raw 32bit numbers into their readable, decimal counterpart?

Your QBasic app seems to have his data stored as floating-point. There have been 2 distinct FP formats (both 64-bit) used see there for details.

IFF the 7.1 version used IEEE you should be able to read the values as "doubles".

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Your QBasic app seems to have his data stored as floating-point. There have been 2 distinct FP formats (both 64-bit) used see there for details.

IFF the 7.1 version used IEEE you should be able to read the values as "doubles".

Yes, they are definitely floating-point numbers. Unfortunately, they are also definitely stored using only 32 bits. It would not appear as though QB7.1 conforms to IEEE-754; that, or these datatypes are being operated on 'manually' in the code and stored using the programmer's own format.

I still have access to the original app, so I'm going to poke at the numbers for a while until I get it figured out. Thanks for your help!

EDIT: I see what's going on now. Actually there were 2 things that threw me off:

1) I have 2 floats that are stored per record in my data file, 1 as a 64-bit double and 1 as a 32-bit single. I was only testing using the 32-bit field, oops!

2) http://support.microsoft.com/kb/140520 -- it turns out they aren't using IEEE, but MBF instead.

I should be good to go. Thanks again!

Edited by jwurmz
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...