diff options
Diffstat (limited to 'bowshock/source/bs/rnd.cxx')
-rw-r--r-- | bowshock/source/bs/rnd.cxx | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/bowshock/source/bs/rnd.cxx b/bowshock/source/bs/rnd.cxx new file mode 100644 index 0000000..32b1b0e --- /dev/null +++ b/bowshock/source/bs/rnd.cxx @@ -0,0 +1,17 @@ +// Copyright 2022-2023 Gabriel Jensen. + +#include <bow/bs.hxx> + +#include <cstdlib> + +static_assert(sizeof (int) == sizeof (::zap::i02)); + +static_assert(RAND_MAX == ::zap::maxval<int>); + +unsigned long ::bow::rnd() noexcept { + ::zap::i02 const rnd0 = (::zap::i02)::std::rand(); + ::zap::i02 const rnd1 = (::zap::i02)::std::rand(); + ::zap::i04 const rnd = (::zap::i04)rnd0 | (::zap::i04)rnd1 >> 0x4u; + + return rnd; +} |