Hacker News new | ask | show | jobs
by eutectic 3418 days ago
A 15 character 64 to 32-bit generator I devised which passes dieharder:

    (x+=x*x+9)>>32;
2 comments

Is dieharder considered as the industry standard tool for testing randomness? Is it commonly used by experts?

https://www.phy.duke.edu/~rgb/General/dieharder.php

Dieharder works OK, and you can easily install it on Ubuntu as a command-line tool. PractRand and TestU01 are more stringent and give you more knobs to play with.
That can be made shorter:

  x+=x*x+9;
Are you sure you don't mean

  x+=((x*x+9)>>32);
(and does that need the outer parentheses?) I doubt the first passes dieharder, as (if my C isn't too rusty) it alternates between odd and even numbers.
I mean you assign the value of the expression to your result.

e.g:

    uint64_t x = 0;
    ...
    uint32_t y = (x+=x*x+9)>>32;