@@ -341,7 +341,7 @@ T rand(T, G)(scope ref G gen, sizediff_t boundExp = 0)
341341 enum ulong EXPMASK = 0x7FF0_0000_0000_0000;
342342 boundExp -= T.min_exp - 1 ;
343343 ulong exp = EXPMASK & u.asInteger;
344- exp = boundExp - (exp ? bsf(exp) - (T.mant_dig - 1 ) : gen.randGeometric + W);
344+ exp = ulong ( boundExp) - (exp ? bsf(exp) - (T.mant_dig - 1 ) : gen.randGeometric + W);
345345 u.asInteger &= ~ EXPMASK ;
346346 if (cast (long )exp < 0 )
347347 {
@@ -454,22 +454,24 @@ T rand(T)(sizediff_t boundExp = 0)
454454{
455455 // Coverage. Impure because uses thread-local.
456456 import mir.math.common: fabs;
457- Random * gen = threadLocalPtr! Random ;
458457
459- auto a = gen .rand! float ;
458+ auto a = rne .rand! float ;
460459 assert (- 1 < a && a < + 1 );
461460
462- auto b = gen .rand! double (4 );
461+ auto b = rne .rand! double (4 );
463462 assert (- 16 < b && b < + 16 );
464463
465- auto c = gen .rand! double (- 2 );
464+ auto c = rne .rand! double (- 2 );
466465 assert (- 0.25 < c && c < + 0.25 );
467466
468- auto d = gen .rand! real .fabs;
467+ auto d = rne .rand! real .fabs;
469468 assert (0.0L <= d && d < 1.0L );
470469
471- auto x = gen.rand! double (double .min_exp- 1 );
472- assert (- double .min_normal < x && x < double .min_normal);
470+ foreach (T; AliasSeq! (float , double , real ))
471+ {
472+ auto f = rne.rand! T(T.min_exp- 1 );
473+ assert (f.fabs < T.min_normal, T.stringof);
474+ }
473475}
474476
475477/+ +
@@ -654,7 +656,7 @@ size_t randGeometric(G)(scope ref G gen)
654656 if (isSaturatedRandomEngine! G)
655657{
656658 alias R = EngineReturnType! G;
657- static if (is (R == ulong ) )
659+ static if (R.sizeof >= size_t .sizeof )
658660 alias T = size_t ;
659661 else
660662 alias T = R;
0 commit comments