|
|
@ -1,6 +1,7 @@
|
|
|
|
#include <bit>
|
|
|
|
#include <bit>
|
|
|
|
|
|
|
|
|
|
|
|
#include <climits>
|
|
|
|
#include <climits>
|
|
|
|
|
|
|
|
#include <cmath>
|
|
|
|
|
|
|
|
|
|
|
|
#include <rng.h>
|
|
|
|
#include <rng.h>
|
|
|
|
#include <mem.h>
|
|
|
|
#include <mem.h>
|
|
|
@ -30,7 +31,7 @@ namespace rng
|
|
|
|
//TODO: properly implemet this f64 crand::_sample() { return (f64)std::bit_cast<u64>(_sample_raw()) / (f64)UINT64_MAX; }
|
|
|
|
//TODO: properly implemet this f64 crand::_sample() { return (f64)std::bit_cast<u64>(_sample_raw()) / (f64)UINT64_MAX; }
|
|
|
|
|
|
|
|
|
|
|
|
// Overrides //
|
|
|
|
// Overrides //
|
|
|
|
u64 crand::next_u64() { return std::bit_cast<u64>(_sample_raw() & INT32_MAX); } // remove sign bit because it messes with the range.
|
|
|
|
u64 crand::next_u64() { return std::bit_cast<u64>(std::abs(_sample_raw()) & INT32_MAX); } // remove sign bit because it messes with the range.
|
|
|
|
|
|
|
|
|
|
|
|
//TODO: Implementing next_i64(i64 max) should be trivial. the man page for drand48 shows its output range, just map that range to `0..=max`
|
|
|
|
//TODO: Implementing next_i64(i64 max) should be trivial. the man page for drand48 shows its output range, just map that range to `0..=max`
|
|
|
|
//TODO: make the default range for all non-bounded `next_i/u*` the same range as drand48's. If that's too big for the integer type, scale it down.
|
|
|
|
//TODO: make the default range for all non-bounded `next_i/u*` the same range as drand48's. If that's too big for the integer type, scale it down.
|
|
|
|