]> git.localhorst.tv Git - blobs.git/blobdiff - src/math/GaloisLFSR.hpp
the return of positive random numbers
[blobs.git] / src / math / GaloisLFSR.hpp
index 592c9afb6a989ab14270756ab844b751c5f4f73c..f9a881c9db32aa2d40ebe9a79adce35c176ce41f 100644 (file)
@@ -56,11 +56,15 @@ public:
        }
 
        double SNorm() noexcept {
-               return 2.0 * UNorm() - 1.0;
+               return (2.0 * UNorm()) - 1.0;
        }
 
        double UNorm() noexcept {
-               return double(Next<std::uint64_t>()) * (1.0 / double(std::numeric_limits<std::uint64_t>::max()));
+               return double(Next<std::uint32_t>()) * (1.0 / double(std::numeric_limits<std::uint32_t>::max()));
+       }
+
+       unsigned int UInt(unsigned int below) noexcept {
+               return ((unsigned int)(UNorm() * double(below))) % below;
        }
 
        template<class Container>