0

I have these numbers from an old database file and I'm looking for the numeric representation this uses.

The numbers are stored as binary format, and they're supposedly 64-bit floating numbers, something like: 54.123 and so on.

I'm posting only natural numbers because that's what I need and the field only contains natural numbers with no fractions.

These are some numbers I have:

  • 00: 00000000
  • 01: 10000100111000000
  • 02: 1000001001110000000
  • 03: 1100001110101000000
  • 04: 100000010011100000000
  • 05: 101000011000011000000
  • 08: 10000000111000100000
  • 09: 100100001011111100000
  • 16: 011100011000000
  • 24: 10000000101010011100000
mskfisher
  • 3,291
  • 4
  • 35
  • 48
Opi
  • 1,288
  • 1
  • 10
  • 14
  • 1
    So where are the rest of the bits, if these are supposedly 64-bit numbers? Did you suppress leading zeros? If so, why is 0 given with so many bits, and why does 16 have 0 in its left-most position? – unwind Jan 27 '12 at 11:21
  • If each number is stored using 64 bits, it might help to show all of those, in order to emphasize the alignment. I'm seeing 8 bits, 15 bits, 23 bits etc. Are they variable length instead? – Vlad Jan 27 '12 at 11:23
  • yeah its funny, I got them like this from the file. They have a maximum value but I guess they're stored as variable length. If that helps its from the old Visual Foxpro File – Opi Jan 27 '12 at 11:24
  • My issue with this is that I'd expect these numbers to be of fixed length for ease of access, or at least have a number of bits that's a multiple of 8. How did you determine that they are represented as shown? – Vlad Jan 27 '12 at 11:32
  • Sorry maybe I didn't give you enough information. I have a bunch of Visual Foxpro Files (.dbf extension) and for some reason I have to read it manually with php (and this cannot be done another way for a specific reason). And because I have these numbers as characters I convert them to their ASCII value by using the ord() function then convert this decimal number to binary number. I don't actually know if thats correct but looking at the number I see some resembles to the numbers they should show so I assume its the correct way. – Opi Jan 27 '12 at 11:35

1 Answers1

1

Apparently, there are PHP classes for reading DBFs: http://www.phpclasses.org/package/1302-PHP-Extract-information-from-a-DBF-database-file.html . They say it doesn't need any extensions, it's all done with PHP functions.

Alternatively, you can inspect the DBF with various viewers to determine the format for that field.

According to this, there are several field types designed to store numbers. This talks about field types and how they're represented.

In any case, from what I understand, Numeric fields might be stored by default as ASCII, and I think are fixed length rather than floating point. So you might get away by using floatval on them.

Vlad
  • 18,195
  • 4
  • 41
  • 71