diff options
author | 2020-06-13 15:58:27 +0200 | |
---|---|---|
committer | 2020-06-13 15:58:27 +0200 | |
commit | 284f196df1c65a91eb38a5a9f31a2da7fb86a1ac (patch) | |
tree | d29473e4024dce305d0ee3bb957a663420417312 /src/lib/netlist/plib/prandom.h | |
parent | 52b8d5fd2b656c317e589da93467c33be74e76ea (diff) | |
parent | e949e9c29de82ee7c32692e7b65da05dd22bdc9d (diff) |
Merge branch 'master' of https://github.com/mamedev/mame
Diffstat (limited to 'src/lib/netlist/plib/prandom.h')
-rw-r--r-- | src/lib/netlist/plib/prandom.h | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/lib/netlist/plib/prandom.h b/src/lib/netlist/plib/prandom.h index 65cdb3e1cf2..b2f9c89a9cf 100644 --- a/src/lib/netlist/plib/prandom.h +++ b/src/lib/netlist/plib/prandom.h @@ -9,6 +9,7 @@ /// #include "pconfig.h" +#include "pgsl.h" #include "pmath.h" #include "ptypes.h" @@ -50,7 +51,7 @@ namespace plib seed(5489); } - static constexpr T min() noexcept { return static_cast<T>(0); } + static constexpr T min() noexcept { return T(0); } static constexpr T max() noexcept { return ~T(0) >> (sizeof(T)*8 - w); } template <typename ST> @@ -103,7 +104,7 @@ namespace plib void twist() { const T lowest_w(~T(0) >> (sizeof(T)*8 - w)); - const T lower_mask((static_cast<T>(1) << r) - 1); // That is, the binary number of r 1's + const T lower_mask((T(1) << r) - 1); // That is, the binary number of r 1's const T upper_mask((~lower_mask) & lowest_w); for (std::size_t i=0; i<N; i++) @@ -122,10 +123,10 @@ namespace plib template <typename FT, typename T> FT normalize_uniform(T &p, FT m = constants<FT>::one(), FT b = constants<FT>::zero()) { - const auto mmin(static_cast<FT>(p.min())); - const auto mmax(static_cast<FT>(p.max())); + const auto mmin(narrow_cast<FT>(p.min())); + const auto mmax(narrow_cast<FT>(p.max())); // -> 0 to a - return (static_cast<FT>(p())- mmin) / (mmax - mmin) * m - b; + return (narrow_cast<FT>(p())- mmin) / (mmax - mmin) * m - b; } template<typename FT> |