On Wed, 2007-03-07 at 14:23 -0800, Andrew Lentvorski wrote:

> 
> That's not 31.31 even if I *do* extend that to the correct number of bits.
> 

I seem to have lost a few bits in my copy-n-paste:

10001111 11000010 11110101 101000 1011100 1001111 111111 1000000

Is what he actually wrote. I didn't check the correctness (guess I
should have, he is an intern after all ;) ), but he did say it is from
this C# program:

double d = 31.31;
byte[] bytes = BitConverter.GetBytes(d);
foreach (byte b in bytes)
{
    Console.Write(b + " ");
}

Which gives the same numbers you have below. However, I noticed that all
the bytes with leading '0' are missing the MSb's, (again) they should be
what you have below. It makes a difference if you string them all
together into one long string of bits.

> See: http://babbage.cs.qc.edu/IEEE-754/Decimal.html
> 
> 31.31 == 403F4F5C28F5C28F
> 
> And Perl agrees (although it is little endian on my Intel machine so you 
> have to flip the order).

I didn't verify if he had the binary conversion correct, but looking on
my own machine, it seems I get the same result as you.
> 
> Converting: 31.31
>       0 143 194 245 040 092 079 063 064
>          8f  c2  f5  28  5c  4f  3f  40
>                       (   \   O   ?   @
> 
> 
> 10001111 11000010 11110101 00101000 01011100 01001111 00111111 01000000

PGA
-- 
Paul G. Allen BSIT/SE
Owner/Sr. Engineer
Random Logic Consulting
www.randomlogic.com

-- 
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg

Reply via email to