Finding the pattern in a set of values

  • Thread starter martix
  • Start date
  • #1
martix
156
0
I have this set of binary values, but the way to arrive at them remains a mystery. I would appreciate some help on that issue.
Code:
Value(LEndian)	Start Diff	Prev Diff	Resulting Multiplier
16256		+0		+0		1
16272		+16		+16		1.125
16288		+32		+16		1.25
16320		+64		+32		1.5
16384		+128		+64		2
16512		+256		+128		4
16640		+384		+128		8
16768		+512		+128		16
16896		+640		+128		32
The question being how do you arrive at the corresponding multiplier from the given value.
 

Answers and Replies

  • #2
I like Serena
Homework Helper
MHB
16,350
256
Hi martix! :smile:

Your Value is the 'single precision' float representation of your Resulting Multiplier.
Or to be more precise, only the top two bytes that should be in there.
See this wiki page for details: http://en.wikipedia.org/wiki/Single_precision

If you want a formula, it's:
[tex]Multiplier = (1 + \frac {Value \textrm{ MOD } 128} {128}) \cdot 2^{Value \textrm{ DIV } 128 - 127}[/tex]
In this formula MOD means to take the remainder after division.
And DIV means to take the integer part after division.

Btw, you missed 2 bytes in your Value. It's supposed to be a 4 byte value.
Those 2 bytes would have been zero for the numbers you've put into your table.
But the consequence would be that the numbers in your Value column should actually be 65536 times as large.
 
Last edited:
  • #3
rcgldr
Homework Helper
8,806
590
Those values are the 16 most significant bits of single precision (32 bit floating point) numbers:

Code:
multiplier      hex      decimal   hex   value
 1.0000 => 3f800000 = 1065353216  3f80 = 16256
 1.1250 => 3f900000 = 1066401792  3f90 = 16272
 1.2500 => 3fa00000 = 1067450368  3fa0 = 16288
 1.5000 => 3fc00000 = 1069547520  3fc0 = 16320
 2.0000 => 40000000 = 1073741824  4000 = 16384
 4.0000 => 40800000 = 1082130432  4080 = 16512
 8.0000 => 41000000 = 1090519040  4100 = 16640
16.0000 => 41800000 = 1098907648  4180 = 16768
32.0000 => 42000000 = 1107296256  4200 = 16896
 
Last edited:
  • #4
I like Serena
Homework Helper
MHB
16,350
256
Those aren't single (32-bit) numbers. For single precision numbers:

Divide your numbers by 65536 and you'll find a match.

Actually, I had just edited my previous post to explain that. ;)
 
  • #5
rcgldr
Homework Helper
8,806
590
Divide your numbers by 65536 and you'll find a match.
Actually, I had just edited my previous post to explain that.
Was in the process of updating my post, it's fixed now.
 
  • #6
I like Serena
Homework Helper
MHB
16,350
256
Was in the process of updating my post, it's fixed now.

Nice table! It clarifies quite neatly what is going on. :smile:
 
  • #7
martix
156
0
I just had a massive FACEPALM. How I didn't see that I have no idea.
The data was in little endian and there were a lot of zeros before those values in every structure they were present so that might have been it.

Anyway, thank you very much!
 

Suggested for: Finding the pattern in a set of values

Replies
29
Views
617
  • Last Post
Replies
19
Views
648
Replies
7
Views
267
Replies
6
Views
411
  • Last Post
Replies
1
Views
504
Replies
0
Views
437
Replies
5
Views
578
Replies
9
Views
926
Top