I've got a really really old file format from an accounting software, late '70s, DOS, QBasic or QuickBasic. Source code is lost, only .exe file remaining, file needs emulator.
The file formate seems to be mainly nullterminated strings and unsigned values, usually 2 bytes / 16 bits in Little Endian notation.
I have received some data and can read most of it, but there's a really strange encoding for the transaction value. I've collected all the data and posted it in a Google Sheet: https://docs.google.com/spreadsheets/d/1hV2cvtVP7YEMxwiEizNZYO89JF_zFhzJbUl9WqWTmx8/edit?usp=sharing (no sign-in required).
I have tried to decode the number.
- It's probably 8bytes/64bits, so the table contains the columns Y-AF for the bytes 0 to 7 (bits 0 to 63).
- These are the only datasets I know the values for.
- The expected value is noted in columns B and AM.
- Converted values are in Columns AI-AL (int8 BE / int8 LE / uint8 BE / uint8 LE), but none of those make any real sense to me
- Values are also plotted, see "Graphs" Tab
I have decoded the last byte (byte 7, column AF) and somewhat matched it with the expected value, IF the first (leftmost) bit is a 1. The (java) formula then is:
final byte lastByte = s.Byte7;
final byte testByte = (byte) (lastByte & 0b01111111);
if (testByte == lastByte) continue; // does not start with 1-bit
final double result = Math.pow(2, testByte - 1);
So in other words, if we have the byte 7 and lose its leading 1, it's v = 2^(byte7-1)
.
This brings exact results for all values being of 2^x
. Any other values are close, but I assume the other bytes need to be taken into account then, too.
Haven't gotten further yet. Perhaps it's an old standard of storing floating point values, but I've never seen this before, and it looks like it has nothing to do with the IEEE floating point numbers of Java, because I tried all conversions (LE/BE, bytes2float/double, signed/unsigned, exponential and logarithmic conversions).
I'll try Base64 and other not-8-bits-per-byte strategies next.
I'll post a bounty of 200 ASAP. (Update: A bounty of 100, as I'm new to this site and only have 101 reputation yet... sorry)
Update: Looks like this is simply the old Microsoft Binary Format. Now I'll write some converting algorithm to read it in Java.