[Newbies] Re: What's wrong with this statement?
nicolas cellier
ncellier at ifrance.com
Fri Aug 1 01:13:32 UTC 2008
Randal L. Schwartz <merlyn <at> stonehenge.com> writes:
>
> >>>>> "johnps11" == johnps11 <johnps11 <at> bigpond.com> writes:
>
> johnps11> I'm not clever enough to understand PRNGs, so I'll leave it others
> johnps11> to work out what the answer is, although I suspect that for more
> johnps11> than 56 bits you need a PRNG that uses LargeIntegers and not Floats.
>
> Yes. There are only 56 bits in an IEEE Float. You can't get any more
> random bits from that.
>
Nah! IEEE 754 double have 53 bit mantissa.
- 1 bit for sign,
- 11 bits for biased exponent,
- 52 bits for mantissa plus a leading implied bit.
+/- 1.m1m2m3...m52 * (2 raisedTo: e1e2...e11 - 1024)
1.0 hex-> '3FF0000000000000' mantissa=16r1.0000000000000 exponent=16r3FF-1024=0
1.5 hex-> '3FF8000000000000' mantissa=16r1.8000000000000 exponent=16r3FF-1024=0
2.5 hex-> '4002000000000000' mantissa=16r1.2000000000000 exponent=16r400-1024=1
this number is thus represented 1.125 * 2
Nicolas
More information about the Beginners
mailing list