If someone know where does the decimal part start (location in bytes, eg. 4th byte), I can use bitwise. |
That scary article also explains that and I warn you IEEE floating point format is itself scary , non-portable (different versions and formats).
But this might help you
http://en.wikipedia.org/wiki/Floating_point
I think you are a bit mistaken.
Let's get to the basics. Say you have a number p = 43.14159 in base 10 represented as 43.14159
10
What does that mean ?
It means that p = 4*10
1 + 3*10
0 + 1*10
-1+ 4*10
-2 + ...
I hope you remember that from math class .
So , similarly a number can be expressed in binary like n = 11.011
2 .
So , n = 1*2
1+1*2
0+0*2
-1+1*2
-2+1*2
-3
which implies n = 3.375 in decimal .
But you cannot express every fraction as such in a base .
For example consider 1/3 which =
0.3333...
10 in base 10 and
0.010101...
2 in base 2 but
0.1
3 in base 3
Now you see the problem , not every number can be expressed in finite sequences ( 'recurring digits' recall from your math class ) so they are only expressed as a close approximation in floating point numbers.
Here's how 1/3 if in is expressed in most desktops (little-endian) in a double-precision number.
555555555555d53f16 , it would be 64 bits in binary.
So as smack89 suggested you should edit your method.
Hope that helps.