Notebooks · lib/nprandom/bits
Unsigned 32- and 64-bit arithmetic on doubles, for NumPy's generators
This module computes in doubles, which hold an integer exactly up to 2^53. NumPy's generators compute with unsigned 32-, 64- and 128-bit integers that wrap around on overflow. This module holds the pieces that keep that arithmetic exact:
- a 32-bit word is a double in [0, 2^32);
band,bor,bxor,shl,shrare Viv builtins that read and return such words; npr_mul32(a, b)isa * b mod 2^32, computed from 16-bit halves so no product passes 2^48;- a 64-bit number is an Int, its unsigned arithmetic the builtins
wrap_add,wrap_mul,umulhiandult; a 128-bit one is two Ints.
Used by the other files of lib/nprandom.
Look inside this program
- Atlas
The program’s map: every function and which calls which.
There’s no recorded run of this program yet.
Shift+Enter in a cell runs it and moves to the next. Running a cell runs every cell above it too, as one program.