decoding binary decimal format

Each row represents a number. The first row corresponds to a value of 1, the second row corresponds to a value of 2, etc.

There is obviously a pattern, but sometimes the numbers seem very strange. I'm trying to decode how the numbers are being stored.

00111111111 1 0000000000000000000000000000000000000000000000000000000000000000000000000000

01000000000 0 0000000000000000000000000000000000000000000000000000000000000000000000000000

01000000000 0 1000000000000000000000000000000000000000000000000000000000000000000000000000

00111111110 100 00000000000000000000000000000000000000000000000000000000000000000000000000

01000000000 101 00000000000000000000000000000000000000000000000000000000000000000000000000

01000000000 110 00000000000000000000000000000000000000000000000000000000000000000000000000

01000000000 111 00000000000000000000000000000000000000000000000000000000000000000000000000

01000000001 0000 0000000000000000000000000000000000000000000000000000000000000000000000000

01000000001 0001 0000000000000000000000000000000000000000000000000000000000000000000000000

01000000001 0010 0000000000000000000000000000000000000000000000000000000000000000000000000

01000000001 0011 0000000000000000000000000000000000000000000000000000000000000000000000000

01000000001 0100 0000000000000000000000000000000000000000000000000000000000000000000000000

01000000001 0101 0000000000000000000000000000000000000000000000000000000000000000000000000

01000000001 0110 0000000000000000000000000000000000000000000000000000000000000000000000000

01000000001 0111 0000000000000000000000000000000000000000000000000000000000000000000000000

01000000001 10000 000000000000000000000000000000000000000000000000000000000000000000000000

00111111101 01110 000111100001111000011110000111100001111000011110000000000000000000000000

01000000001 10010 000000000000000000000000000000000000000000000000000000000000000000000000

01000000001 10011 000000000000000000000000000000000000000000000000000000000000000000000000

01000000001 10100 000000000000000000000000000000000000000000000000000000000000000000000000

01000000001 10101 000000000000000000000000000000000000000000000000000000000000000000000000

01000000001 10110 000000000000000000000000000000000000000000000000000000000000000000000000

01000000001 10111 000000000000000000000000000000000000000000000000000000000000000000000000

01000000001 11000 000000000000000000000000000000000000000000000000000000000000000000000000

01000000001 11001 000000000000000000000000000000000000000000000000000000000000000000000000

01000000001 11010 000000000000000000000000000000000000000000000000000000000000000000000000

01000000001 11011 000000000000000000000000000000000000000000000000000000000000000000000000

01000000001 11100 000000000000000000000000000000000000000000000000000000000000000000000000

00111111101 00001 101001111011100101100001000110100111101110010110000000000000000000000000

01000000001 11110 000000000000000000000000000000000000000000000000000000000000000000000000

01000000001 11111 000000000000000000000000000000000000000000000000000000000000000000000000

010000000 1 00 00000 00000000000000000000000000000000000000000000000000000000000000000000000

010000000 1 00 00001 00000000000000000000000000000000000000000000000000000000000000000000000

010000000 1 00 00010 00000000000000000000000000000000000000000000000000000000000000000000000

010000000 1 00 00011 00000000000000000000000000000000000000000000000000000000000000000000000

010000000 1 00 00100 00000000000000000000000000000000000000000000000000000000000000000000000

010000000 1 00 00101 00000000000000000000000000000000000000000000000000000000000000000000000

010000000 1 00 00110 00000000000000000000000000000000000000000000000000000000000000000000000

010000000 1 00 00111 00000000000000000000000000000000000000000000000000000000000000000000000

010000000 1 00 01000 00000000000000000000000000000000000000000000000000000000000000000000000

010000000 1 00 01001 00000000000000000000000000000000000000000000000000000000000000000000000

001111111 0 01 10000 11000011000011000011000011000011000011000011000000000000000000000000000

010000000 1 00 01011 00000000000000000000000000000000000000000000000000000000000000000000000

010000000 1 00 01100 00000000000000000000000000000000000000000000000000000000000000000000000

010000000 1 00 01101 00000000000000000000000000000000000000000000000000000000000000000000000

010000000 1 00 01110 00000000000000000000000000000000000000000000000000000000000000000000000

010000000 1 00 01111 00000000000000000000000000000000000000000000000000000000000000000000000

010000000 1 00 10000 00000000000000000000000000000000000000000000000000000000000000000000000

010000000 1 00 10001 00000000000000000000000000000000000000000000000000000000000000000000000

010000000 1 00 10010 00000000000000000000000000000000000000000000000000000000000000000000000

010000000 1 00 10011 00000000000000000000000000000000000000000000000000000000000000000000000

010000000 1 00 10100 00000000000000000000000000000000000000000000000000000000000000000000000

010000000 1 00 10101 00000000000000000000000000000000000000000000000000000000000000000000000

001111111 0 01 00101 11101101000010010111101101000010010111101101000000000000000000000000000

010000000 1 00 10111 00000000000000000000000000000000000000000000000000000000000000000000000

010000000 1 00 11000 00000000000000000000000000000000000000000000000000000000000000000000000

010000000 1 00 11001 00000000000000000000000000000000000000000000000000000000000000000000000

010000000 1 00 11010 00000000000000000000000000000000000000000000000000000000000000000000000

010000000 1 00 11011 00000000000000000000000000000000000000000000000000000000000000000000000

010000000 1 00 11100 00000000000000000000000000000000000000000000000000000000000000000000000

010000000 1 00 11101 00000000000000000000000000000000000000000000000000000000000000000000000

010000000 1 00 11110 00000000000000000000000000000000000000000000000000000000000000000000000

010000000 1 00 11111 00000000000000000000000000000000000000000000000000000000000000000000000

010000000 1 01 00000 00000000000000000000000000000000000000000000000000000000000000000000000

010000000 1 01 000001 0000000000000000000000000000000000000000000000000000000000000000000000

010000000 1 01 000010 0000000000000000000000000000000000000000000000000000000000000000000000

001111111 0 00 111010 0100010011000110101011111100001011011101100111000000000000000000000000

010000000 1 01 000100 0000000000000000000000000000000000000000000000000000000000000000000000

010000000 1 01 000101 0000000000000000000000000000000000000000000000000000000000000000000000

010000000 1 01 000110 0000000000000000000000000000000000000000000000000000000000000000000000

010000000 1 01 000111 0000000000000000000000000000000000000000000000000000000000000000000000

010000000 1 01 001000 0000000000000000000000000000000000000000000000000000000000000000000000

010000000 1 01 001001 0000000000000000000000000000000000000000000000000000000000000000000000

010000000 1 01 001010 0000000000000000000000000000000000000000000000000000000000000000000000

010000000 1 01 001011 0000000000000000000000000000000000000000000000000000000000000000000000

[7628 byte] By [rkippena] at [2007-11-26 17:02:25]
# 1

What the shizzle produced that?!@#

You have three columns. What the heck cause that random accumalation. Its as though it was suppose to be a binary addition by 1 pattern (which you mentioned) but its messed up. right?

Ok, tell me, where did you get these numbers from, and why is there so many worthless 0's floating all over the place?

Alos, why are there 4 columns some times?@!#

AAAHH@@@###$$%%%!!!

ArikArikArika at 2007-7-8 23:30:11 > top of Java-index,Other Topics,Algorithms...
# 2

i added spaces to make it more clear where I think the pattern is occurring. You can ignore the trailing 0s, they are used for the fraction part of the number (I think). As for the software, it's a really poorly designed, made by a company that has a monopoly on financial software, and it also has our data trapped (vendor lock in). They call their format "proprietary" (I can think of a better term for it), and so they are not willing to help us.

rkippena at 2007-7-8 23:30:11 > top of Java-index,Other Topics,Algorithms...
# 3
Maybe every row has also some additional meaning, not only representing a simple numeric value.
beradriana at 2007-7-8 23:30:11 > top of Java-index,Other Topics,Algorithms...
# 4

I can't explain the occasional entries that start with 00111111

However the rest seem to fall into the following format

Strip off the first 12 bits

if the high order 2 bits are 00 then you have the pattern that I can't explain

if on the other hand the top 2 are 01, then the remaining 10 bits is and indicator of where the high bit in the original number is. Call that number that you got from the remaining 10 bits X. Because X tells you where the high order bit is, it tells you what power of 2 you must start with in reassembling the int, and it also tells you how many bits you must read out of the remaining bits to complete the number

Your final number will be 2^(X+1) + (next (X+1) bits from the data stream)

so for numbers between 2 and 3, high order bit is 2^1 so X will be 0 and you need to read (0+1) aditional bits i.e. you need to read the one other bit that follows the high order bit.

for numbers between 4 and 7 high order bit is 2^2 so X is 1 and you will need to read (1+1) additional bits which are the two following the high order bit.

It is easier to see if you put the spaces in the right place.

FF XXXXXXXXXX bits-after-most-significant-bit

00 1111111111 0000000000000000000000000000000000000000000000000000000000000000000000000000 1

01 0000000000 0 000000000000000000000000000000000000000000000000000000000000000000000000000 2

01 0000000000 1 000000000000000000000000000000000000000000000000000000000000000000000000000 3

00 1111111101 00 00000000000000000000000000000000000000000000000000000000000000000000000000 4

01 0000000001 01 00000000000000000000000000000000000000000000000000000000000000000000000000 5

01 0000000001 10 00000000000000000000000000000000000000000000000000000000000000000000000000 6

01 0000000001 11 00000000000000000000000000000000000000000000000000000000000000000000000000 7

01 0000000010 000 0000000000000000000000000000000000000000000000000000000000000000000000000 8

01 0000000010 001 0000000000000000000000000000000000000000000000000000000000000000000000000 9

01 0000000010 010 0000000000000000000000000000000000000000000000000000000000000000000000000 10

01 0000000010 011 0000000000000000000000000000000000000000000000000000000000000000000000000 11

01 0000000010 100 0000000000000000000000000000000000000000000000000000000000000000000000000 12

01 0000000010 101 0000000000000000000000000000000000000000000000000000000000000000000000000 13

01 0000000010 110 0000000000000000000000000000000000000000000000000000000000000000000000000 14

01 0000000010 111 0000000000000000000000000000000000000000000000000000000000000000000000000 15

01 0000000011 0000 000000000000000000000000000000000000000000000000000000000000000000000000 16

00 1111111010 1110 000111100001111000011110000111100001111000011110000000000000000000000000 17

01 0000000011 0010 000000000000000000000000000000000000000000000000000000000000000000000000 18

01 0000000011 0011 000000000000000000000000000000000000000000000000000000000000000000000000 19

01 0000000011 0100 000000000000000000000000000000000000000000000000000000000000000000000000 20

01 0000000011 0101 000000000000000000000000000000000000000000000000000000000000000000000000 21

01 0000000011 0110 000000000000000000000000000000000000000000000000000000000000000000000000 22

01 0000000011 0111 000000000000000000000000000000000000000000000000000000000000000000000000 23

01 0000000011 1000 000000000000000000000000000000000000000000000000000000000000000000000000 24

01 0000000011 1001 000000000000000000000000000000000000000000000000000000000000000000000000 25

01 0000000011 1010 000000000000000000000000000000000000000000000000000000000000000000000000 26

01 0000000011 1011 000000000000000000000000000000000000000000000000000000000000000000000000 27

01 0000000011 1100 000000000000000000000000000000000000000000000000000000000000000000000000 28

00 1111111010 0001 101001111011100101100001000110100111101110010110000000000000000000000000 29

01 0000000011 1110 000000000000000000000000000000000000000000000000000000000000000000000000 30

01 0000000011 1111 000000000000000000000000000000000000000000000000000000000000000000000000 31

01 0000000100 00000 00000000000000000000000000000000000000000000000000000000000000000000000 32

01 0000000100 00001 00000000000000000000000000000000000000000000000000000000000000000000000

01 0000000100 00010 00000000000000000000000000000000000000000000000000000000000000000000000

01 0000000100 00011 00000000000000000000000000000000000000000000000000000000000000000000000

01 0000000100 00100 00000000000000000000000000000000000000000000000000000000000000000000000

marlin314a at 2007-7-8 23:30:11 > top of Java-index,Other Topics,Algorithms...
# 5

Looks remarkably like IEEE 754;

1-bit sign, 11-bit exponent (bias 1023), rest mantissa (implicit leading 1).

s=0 e=01111111111 m=10000000000000000: + b1 x 2^0 = 1

s=0 e=10000000000 m=10000000000000000: + b1 x 2^1 = b10 = 2

s=0 e=10000000000 m=11000000000000000: + b1.1 x 2^1 = b11 = 3

s=0 e=01111111101 m=10000000000000000: looks broken, would be + b1 x 2^-2 = b0.01 = 0.25

s=0 e=10000000001 m=10100000000000000: + b1.01 x 2^2 = b101 = 5

s=0 e=10000000001 m=11000000000000000: + b1.1 x 2^2 = b110 = 6

s=0 e=10000000001 m=11100000000000000: + b1.11 x 2^2 = b111 = 7

s=0 e=10000000010 m=10000000000000000: + b1 x 2^3 = b1000 = 8

s=0 e=10000000010 m=10010000000000000: + b1.001 x 2^3 = b1001 = 9

tschodta at 2007-7-8 23:30:11 > top of Java-index,Other Topics,Algorithms...
# 6

> Looks remarkably like IEEE 754;

> 1-bit sign, 11-bit exponent (bias 1023), rest

> mantissa (implicit leading 1).

> s=0 e=01111111101 m=10000000000000000: looks

> broken, would be + b1 x 2^-2 = b0.01 = 0.25

OK, this could be wrong but in a cursory look at the value for 17, it appears it may be the reciprocal of 17 as the value for 4 is the reciprocal of 4. Anyone care to check?

If it's the case that these 'odd' values are reciprocals, then it's probably done to throw you off. The next question is how do you know which numbers they do this for?

dubwaia at 2007-7-8 23:30:11 > top of Java-index,Other Topics,Algorithms...
# 7
If the reciprocal thing pans out, then it appears that they use the reciprocal every 12th or 13th value (alternating).Ugly stuff. And people look at me like I'm crazy when I warn about proprietary lock-in.
dubwaia at 2007-7-8 23:30:11 > top of Java-index,Other Topics,Algorithms...
# 8

Thanks to everyone for your insights. It seems that the bits are IEEE 754, but not all the time. Sometimes they are the reciprocal. So now it is a matter of detecting when a reciprocal number is entered. There is a method in the Double class for converting longToDouble(long bits)

1.0

2.0

3.0

4.0

5.0

6.0

7.0

8.0

9.0

10.0

11.0

12.0

13.0

0.07142857142857142

15.0

16.0

17.0

18.0

19.0

20.0

21.0

22.0

23.0

24.0

25.0

26.0

27.0

28.0

0.034482758620689655

30.0

31.0

32.0

33.0

34.0

35.0

36.0

37.0

38.0

39.0

40.0

41.0

0.023809523809523808

43.0

44.0

45.0

46.0

47.0

48.0

49.0

50.0

rkippena at 2007-7-8 23:30:11 > top of Java-index,Other Topics,Algorithms...
# 9

In your original post 17 was reciprocal and in this last post

it appears to be 14 that is reciprocal. Is it changing over time?

Do you know when whether you are working with integers or not?

If you know you are working with whole numbers, could you just

get the reciprocal whenever the value is less than 1 and greater than 0?

dubwaia at 2007-7-8 23:30:11 > top of Java-index,Other Topics,Algorithms...
# 10

> Do you know when whether you are working with integers or not?

No. This files I'm decoding are exchange rates between different currencies. All the values are typically fractions, however there is a chance that the exchange ratio will be a whole number,.

> In your original post 17 was reciprocal and in this last post

> it appears to be 14 that is reciprocal.

It is very strange. It looks like the product is looking at the exchange rate identifier (e.g. "jp" for Japanese Yen) and inverting it. So I will have to see what exchange rates it applies the invert to.

The reason it was reversing every 12 and 13 is because our currency file has 25 currencies, and ca is #4 and jp is #17. So, it looks like:

1

2

3

4 (ca)

5

6

7

8

9

10

11

12

13

14

15

16

17 (jp)

18

19

20

21

22

23

24

25

1 (26)

2 (27)

3 (28)

4 (29)

29 - 17 = 12

17 - 3 = 13

Thanks.

rkippena at 2007-7-8 23:30:11 > top of Java-index,Other Topics,Algorithms...