X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmath%2FGaloisLFSR.hpp;h=e2f39ebb5110eb348ea26f57dcb377933a0ee5e6;hb=d364d8a9203138be1c569cdc31144f51883ec79f;hp=592c9afb6a989ab14270756ab844b751c5f4f73c;hpb=8f6530c75730f901efd6708e4fde7e68a178adf1;p=blobs.git diff --git a/src/math/GaloisLFSR.hpp b/src/math/GaloisLFSR.hpp index 592c9af..e2f39eb 100644 --- a/src/math/GaloisLFSR.hpp +++ b/src/math/GaloisLFSR.hpp @@ -56,13 +56,17 @@ public: } double SNorm() noexcept { - return 2.0 * UNorm() - 1.0; + return (2.0 * UNorm()) - 1.0; } double UNorm() noexcept { return double(Next()) * (1.0 / double(std::numeric_limits::max())); } + unsigned int UInt(unsigned int below) noexcept { + return ((unsigned int)(UNorm() * double(below))) % below; + } + template typename Container::reference From(Container &c) { assert(c.size() > 0);