Hacker News new | ask | show | jobs
by PhantomGremlin 4258 days ago
At least one, possibly two other bugs lurking in the implementation.

1) Algorithm FT says:

    1. Generate u. Store the first bit of u
    as a sign s (s=0 if u<1/2, s=1 if u>=1/2).
and yet the C code implements

    if ( u <= 0.5 ) s = 0.0;
    else s = 1.0;
2) I can't be sure of the following w/o access to doc. But i4_uni() says

    a uniform distribution over (1, 2147483562)
which, offhand, is suspicious. A distribution over positive integers would probably want to use all available values in a 32-bit signed int, so it would most likely end at 2^31 -1 which is 2147483647, and not the value given.
1 comments

Good point about the C code. OTOH, 2147483562 is 1 less than a prime, which is unlikely to be an accident.