1--TEST--
2Random: Randomizer: getFloat(): Returned floats have equal distance.
3--FILE--
4<?php
5
6use Random\Engine;
7use Random\Engine\Test\TestCountingEngine64;
8use Random\IntervalBoundary;
9use Random\Randomizer;
10
11require __DIR__ . "/../../engines.inc";
12
13function run_test(Randomizer $r, float $min, float $max, int $count) {
14    printf("[%.17g, %.17g]\n", $min, $max);
15
16    $prev = null;
17    for ($i = 0; $i < $count; $i++) {
18        $float = $r->getFloat($min, $max, IntervalBoundary::ClosedClosed);
19        printf("%.17f", $float);
20        if ($prev !== null) {
21            printf(" (%+.17g)", ($float - $prev));
22
23            if ($prev < $float) {
24                printf("\nRepeat");
25            }
26        }
27        printf("\n");
28
29        $prev = $float;
30    }
31}
32
33run_test(
34    new Randomizer(new TestCountingEngine64()),
35    1.99999999999999,
36    2.00000000000001,
37    150,
38);
39
40echo "==================", PHP_EOL, PHP_EOL;
41
42run_test(
43    new Randomizer(new TestCountingEngine64()),
44    1.99999999999999,
45    2.00000000000000,
46    150,
47);
48
49echo "==================", PHP_EOL, PHP_EOL;
50
51run_test(
52    new Randomizer(new TestCountingEngine64()),
53    2.00000000000000,
54    2.00000000000001,
55    60,
56);
57
58?>
59--EXPECT--
60[1.99999999999999, 2.0000000000000102]
612.00000000000001021
622.00000000000000977 (-4.4408920985006262e-16)
632.00000000000000933 (-4.4408920985006262e-16)
642.00000000000000888 (-4.4408920985006262e-16)
652.00000000000000844 (-4.4408920985006262e-16)
662.00000000000000799 (-4.4408920985006262e-16)
672.00000000000000755 (-4.4408920985006262e-16)
682.00000000000000711 (-4.4408920985006262e-16)
692.00000000000000666 (-4.4408920985006262e-16)
702.00000000000000622 (-4.4408920985006262e-16)
712.00000000000000577 (-4.4408920985006262e-16)
722.00000000000000533 (-4.4408920985006262e-16)
732.00000000000000488 (-4.4408920985006262e-16)
742.00000000000000444 (-4.4408920985006262e-16)
752.00000000000000400 (-4.4408920985006262e-16)
762.00000000000000355 (-4.4408920985006262e-16)
772.00000000000000311 (-4.4408920985006262e-16)
782.00000000000000266 (-4.4408920985006262e-16)
792.00000000000000222 (-4.4408920985006262e-16)
802.00000000000000178 (-4.4408920985006262e-16)
812.00000000000000133 (-4.4408920985006262e-16)
822.00000000000000089 (-4.4408920985006262e-16)
832.00000000000000044 (-4.4408920985006262e-16)
842.00000000000000000 (-4.4408920985006262e-16)
851.99999999999999956 (-4.4408920985006262e-16)
861.99999999999999911 (-4.4408920985006262e-16)
871.99999999999999867 (-4.4408920985006262e-16)
881.99999999999999822 (-4.4408920985006262e-16)
891.99999999999999778 (-4.4408920985006262e-16)
901.99999999999999734 (-4.4408920985006262e-16)
911.99999999999999689 (-4.4408920985006262e-16)
921.99999999999999645 (-4.4408920985006262e-16)
931.99999999999999600 (-4.4408920985006262e-16)
941.99999999999999556 (-4.4408920985006262e-16)
951.99999999999999512 (-4.4408920985006262e-16)
961.99999999999999467 (-4.4408920985006262e-16)
971.99999999999999423 (-4.4408920985006262e-16)
981.99999999999999378 (-4.4408920985006262e-16)
991.99999999999999334 (-4.4408920985006262e-16)
1001.99999999999999289 (-4.4408920985006262e-16)
1011.99999999999999245 (-4.4408920985006262e-16)
1021.99999999999999201 (-4.4408920985006262e-16)
1031.99999999999999156 (-4.4408920985006262e-16)
1041.99999999999999112 (-4.4408920985006262e-16)
1051.99999999999999067 (-4.4408920985006262e-16)
1061.99999999999999023 (-4.4408920985006262e-16)
1071.99999999999999001 (-2.2204460492503131e-16)
1082.00000000000001021 (+2.0206059048177849e-14)
109Repeat
1102.00000000000000977 (-4.4408920985006262e-16)
1112.00000000000000933 (-4.4408920985006262e-16)
1122.00000000000000888 (-4.4408920985006262e-16)
1132.00000000000000844 (-4.4408920985006262e-16)
1142.00000000000000799 (-4.4408920985006262e-16)
1152.00000000000000755 (-4.4408920985006262e-16)
1162.00000000000000711 (-4.4408920985006262e-16)
1172.00000000000000666 (-4.4408920985006262e-16)
1182.00000000000000622 (-4.4408920985006262e-16)
1192.00000000000000577 (-4.4408920985006262e-16)
1202.00000000000000533 (-4.4408920985006262e-16)
1212.00000000000000488 (-4.4408920985006262e-16)
1222.00000000000000444 (-4.4408920985006262e-16)
1232.00000000000000400 (-4.4408920985006262e-16)
1242.00000000000000355 (-4.4408920985006262e-16)
1252.00000000000000311 (-4.4408920985006262e-16)
1262.00000000000000266 (-4.4408920985006262e-16)
1272.00000000000000222 (-4.4408920985006262e-16)
1282.00000000000000178 (-4.4408920985006262e-16)
1292.00000000000000133 (-4.4408920985006262e-16)
1302.00000000000000089 (-4.4408920985006262e-16)
1312.00000000000000044 (-4.4408920985006262e-16)
1322.00000000000000000 (-4.4408920985006262e-16)
1331.99999999999999956 (-4.4408920985006262e-16)
1341.99999999999999911 (-4.4408920985006262e-16)
1351.99999999999999867 (-4.4408920985006262e-16)
1361.99999999999999822 (-4.4408920985006262e-16)
1371.99999999999999778 (-4.4408920985006262e-16)
1381.99999999999999734 (-4.4408920985006262e-16)
1391.99999999999999689 (-4.4408920985006262e-16)
1401.99999999999999645 (-4.4408920985006262e-16)
1411.99999999999999600 (-4.4408920985006262e-16)
1421.99999999999999556 (-4.4408920985006262e-16)
1431.99999999999999512 (-4.4408920985006262e-16)
1441.99999999999999467 (-4.4408920985006262e-16)
1451.99999999999999423 (-4.4408920985006262e-16)
1461.99999999999999378 (-4.4408920985006262e-16)
1471.99999999999999334 (-4.4408920985006262e-16)
1481.99999999999999289 (-4.4408920985006262e-16)
1491.99999999999999245 (-4.4408920985006262e-16)
1501.99999999999999201 (-4.4408920985006262e-16)
1511.99999999999999156 (-4.4408920985006262e-16)
1521.99999999999999112 (-4.4408920985006262e-16)
1531.99999999999999067 (-4.4408920985006262e-16)
1541.99999999999999023 (-4.4408920985006262e-16)
1551.99999999999999001 (-2.2204460492503131e-16)
1562.00000000000001021 (+2.0206059048177849e-14)
157Repeat
1582.00000000000000977 (-4.4408920985006262e-16)
1592.00000000000000933 (-4.4408920985006262e-16)
1602.00000000000000888 (-4.4408920985006262e-16)
1612.00000000000000844 (-4.4408920985006262e-16)
1622.00000000000000799 (-4.4408920985006262e-16)
1632.00000000000000755 (-4.4408920985006262e-16)
1642.00000000000000711 (-4.4408920985006262e-16)
1652.00000000000000666 (-4.4408920985006262e-16)
1662.00000000000000622 (-4.4408920985006262e-16)
1672.00000000000000577 (-4.4408920985006262e-16)
1682.00000000000000533 (-4.4408920985006262e-16)
1692.00000000000000488 (-4.4408920985006262e-16)
1702.00000000000000444 (-4.4408920985006262e-16)
1712.00000000000000400 (-4.4408920985006262e-16)
1722.00000000000000355 (-4.4408920985006262e-16)
1732.00000000000000311 (-4.4408920985006262e-16)
1742.00000000000000266 (-4.4408920985006262e-16)
1752.00000000000000222 (-4.4408920985006262e-16)
1762.00000000000000178 (-4.4408920985006262e-16)
1772.00000000000000133 (-4.4408920985006262e-16)
1782.00000000000000089 (-4.4408920985006262e-16)
1792.00000000000000044 (-4.4408920985006262e-16)
1802.00000000000000000 (-4.4408920985006262e-16)
1811.99999999999999956 (-4.4408920985006262e-16)
1821.99999999999999911 (-4.4408920985006262e-16)
1831.99999999999999867 (-4.4408920985006262e-16)
1841.99999999999999822 (-4.4408920985006262e-16)
1851.99999999999999778 (-4.4408920985006262e-16)
1861.99999999999999734 (-4.4408920985006262e-16)
1871.99999999999999689 (-4.4408920985006262e-16)
1881.99999999999999645 (-4.4408920985006262e-16)
1891.99999999999999600 (-4.4408920985006262e-16)
1901.99999999999999556 (-4.4408920985006262e-16)
1911.99999999999999512 (-4.4408920985006262e-16)
1921.99999999999999467 (-4.4408920985006262e-16)
1931.99999999999999423 (-4.4408920985006262e-16)
1941.99999999999999378 (-4.4408920985006262e-16)
1951.99999999999999334 (-4.4408920985006262e-16)
1961.99999999999999289 (-4.4408920985006262e-16)
1971.99999999999999245 (-4.4408920985006262e-16)
1981.99999999999999201 (-4.4408920985006262e-16)
1991.99999999999999156 (-4.4408920985006262e-16)
2001.99999999999999112 (-4.4408920985006262e-16)
2011.99999999999999067 (-4.4408920985006262e-16)
2021.99999999999999023 (-4.4408920985006262e-16)
2031.99999999999999001 (-2.2204460492503131e-16)
2042.00000000000001021 (+2.0206059048177849e-14)
205Repeat
2062.00000000000000977 (-4.4408920985006262e-16)
2072.00000000000000933 (-4.4408920985006262e-16)
2082.00000000000000888 (-4.4408920985006262e-16)
2092.00000000000000844 (-4.4408920985006262e-16)
2102.00000000000000799 (-4.4408920985006262e-16)
2112.00000000000000755 (-4.4408920985006262e-16)
2122.00000000000000711 (-4.4408920985006262e-16)
2132.00000000000000666 (-4.4408920985006262e-16)
214==================
215
216[1.99999999999999, 2]
2172.00000000000000000
2181.99999999999999978 (-2.2204460492503131e-16)
2191.99999999999999956 (-2.2204460492503131e-16)
2201.99999999999999933 (-2.2204460492503131e-16)
2211.99999999999999911 (-2.2204460492503131e-16)
2221.99999999999999889 (-2.2204460492503131e-16)
2231.99999999999999867 (-2.2204460492503131e-16)
2241.99999999999999845 (-2.2204460492503131e-16)
2251.99999999999999822 (-2.2204460492503131e-16)
2261.99999999999999800 (-2.2204460492503131e-16)
2271.99999999999999778 (-2.2204460492503131e-16)
2281.99999999999999756 (-2.2204460492503131e-16)
2291.99999999999999734 (-2.2204460492503131e-16)
2301.99999999999999711 (-2.2204460492503131e-16)
2311.99999999999999689 (-2.2204460492503131e-16)
2321.99999999999999667 (-2.2204460492503131e-16)
2331.99999999999999645 (-2.2204460492503131e-16)
2341.99999999999999623 (-2.2204460492503131e-16)
2351.99999999999999600 (-2.2204460492503131e-16)
2361.99999999999999578 (-2.2204460492503131e-16)
2371.99999999999999556 (-2.2204460492503131e-16)
2381.99999999999999534 (-2.2204460492503131e-16)
2391.99999999999999512 (-2.2204460492503131e-16)
2401.99999999999999489 (-2.2204460492503131e-16)
2411.99999999999999467 (-2.2204460492503131e-16)
2421.99999999999999445 (-2.2204460492503131e-16)
2431.99999999999999423 (-2.2204460492503131e-16)
2441.99999999999999400 (-2.2204460492503131e-16)
2451.99999999999999378 (-2.2204460492503131e-16)
2461.99999999999999356 (-2.2204460492503131e-16)
2471.99999999999999334 (-2.2204460492503131e-16)
2481.99999999999999312 (-2.2204460492503131e-16)
2491.99999999999999289 (-2.2204460492503131e-16)
2501.99999999999999267 (-2.2204460492503131e-16)
2511.99999999999999245 (-2.2204460492503131e-16)
2521.99999999999999223 (-2.2204460492503131e-16)
2531.99999999999999201 (-2.2204460492503131e-16)
2541.99999999999999178 (-2.2204460492503131e-16)
2551.99999999999999156 (-2.2204460492503131e-16)
2561.99999999999999134 (-2.2204460492503131e-16)
2571.99999999999999112 (-2.2204460492503131e-16)
2581.99999999999999090 (-2.2204460492503131e-16)
2591.99999999999999067 (-2.2204460492503131e-16)
2601.99999999999999045 (-2.2204460492503131e-16)
2611.99999999999999023 (-2.2204460492503131e-16)
2621.99999999999999001 (-2.2204460492503131e-16)
2632.00000000000000000 (+9.9920072216264089e-15)
264Repeat
2651.99999999999999978 (-2.2204460492503131e-16)
2661.99999999999999956 (-2.2204460492503131e-16)
2671.99999999999999933 (-2.2204460492503131e-16)
2681.99999999999999911 (-2.2204460492503131e-16)
2691.99999999999999889 (-2.2204460492503131e-16)
2701.99999999999999867 (-2.2204460492503131e-16)
2711.99999999999999845 (-2.2204460492503131e-16)
2721.99999999999999822 (-2.2204460492503131e-16)
2731.99999999999999800 (-2.2204460492503131e-16)
2741.99999999999999778 (-2.2204460492503131e-16)
2751.99999999999999756 (-2.2204460492503131e-16)
2761.99999999999999734 (-2.2204460492503131e-16)
2771.99999999999999711 (-2.2204460492503131e-16)
2781.99999999999999689 (-2.2204460492503131e-16)
2791.99999999999999667 (-2.2204460492503131e-16)
2801.99999999999999645 (-2.2204460492503131e-16)
2811.99999999999999623 (-2.2204460492503131e-16)
2821.99999999999999600 (-2.2204460492503131e-16)
2831.99999999999999578 (-2.2204460492503131e-16)
2841.99999999999999556 (-2.2204460492503131e-16)
2851.99999999999999534 (-2.2204460492503131e-16)
2861.99999999999999512 (-2.2204460492503131e-16)
2871.99999999999999489 (-2.2204460492503131e-16)
2881.99999999999999467 (-2.2204460492503131e-16)
2891.99999999999999445 (-2.2204460492503131e-16)
2901.99999999999999423 (-2.2204460492503131e-16)
2911.99999999999999400 (-2.2204460492503131e-16)
2921.99999999999999378 (-2.2204460492503131e-16)
2931.99999999999999356 (-2.2204460492503131e-16)
2941.99999999999999334 (-2.2204460492503131e-16)
2951.99999999999999312 (-2.2204460492503131e-16)
2961.99999999999999289 (-2.2204460492503131e-16)
2971.99999999999999267 (-2.2204460492503131e-16)
2981.99999999999999245 (-2.2204460492503131e-16)
2991.99999999999999223 (-2.2204460492503131e-16)
3001.99999999999999201 (-2.2204460492503131e-16)
3011.99999999999999178 (-2.2204460492503131e-16)
3021.99999999999999156 (-2.2204460492503131e-16)
3031.99999999999999134 (-2.2204460492503131e-16)
3041.99999999999999112 (-2.2204460492503131e-16)
3051.99999999999999090 (-2.2204460492503131e-16)
3061.99999999999999067 (-2.2204460492503131e-16)
3071.99999999999999045 (-2.2204460492503131e-16)
3081.99999999999999023 (-2.2204460492503131e-16)
3091.99999999999999001 (-2.2204460492503131e-16)
3102.00000000000000000 (+9.9920072216264089e-15)
311Repeat
3121.99999999999999978 (-2.2204460492503131e-16)
3131.99999999999999956 (-2.2204460492503131e-16)
3141.99999999999999933 (-2.2204460492503131e-16)
3151.99999999999999911 (-2.2204460492503131e-16)
3161.99999999999999889 (-2.2204460492503131e-16)
3171.99999999999999867 (-2.2204460492503131e-16)
3181.99999999999999845 (-2.2204460492503131e-16)
3191.99999999999999822 (-2.2204460492503131e-16)
3201.99999999999999800 (-2.2204460492503131e-16)
3211.99999999999999778 (-2.2204460492503131e-16)
3221.99999999999999756 (-2.2204460492503131e-16)
3231.99999999999999734 (-2.2204460492503131e-16)
3241.99999999999999711 (-2.2204460492503131e-16)
3251.99999999999999689 (-2.2204460492503131e-16)
3261.99999999999999667 (-2.2204460492503131e-16)
3271.99999999999999645 (-2.2204460492503131e-16)
3281.99999999999999623 (-2.2204460492503131e-16)
3291.99999999999999600 (-2.2204460492503131e-16)
3301.99999999999999578 (-2.2204460492503131e-16)
3311.99999999999999556 (-2.2204460492503131e-16)
3321.99999999999999534 (-2.2204460492503131e-16)
3331.99999999999999512 (-2.2204460492503131e-16)
3341.99999999999999489 (-2.2204460492503131e-16)
3351.99999999999999467 (-2.2204460492503131e-16)
3361.99999999999999445 (-2.2204460492503131e-16)
3371.99999999999999423 (-2.2204460492503131e-16)
3381.99999999999999400 (-2.2204460492503131e-16)
3391.99999999999999378 (-2.2204460492503131e-16)
3401.99999999999999356 (-2.2204460492503131e-16)
3411.99999999999999334 (-2.2204460492503131e-16)
3421.99999999999999312 (-2.2204460492503131e-16)
3431.99999999999999289 (-2.2204460492503131e-16)
3441.99999999999999267 (-2.2204460492503131e-16)
3451.99999999999999245 (-2.2204460492503131e-16)
3461.99999999999999223 (-2.2204460492503131e-16)
3471.99999999999999201 (-2.2204460492503131e-16)
3481.99999999999999178 (-2.2204460492503131e-16)
3491.99999999999999156 (-2.2204460492503131e-16)
3501.99999999999999134 (-2.2204460492503131e-16)
3511.99999999999999112 (-2.2204460492503131e-16)
3521.99999999999999090 (-2.2204460492503131e-16)
3531.99999999999999067 (-2.2204460492503131e-16)
3541.99999999999999045 (-2.2204460492503131e-16)
3551.99999999999999023 (-2.2204460492503131e-16)
3561.99999999999999001 (-2.2204460492503131e-16)
3572.00000000000000000 (+9.9920072216264089e-15)
358Repeat
3591.99999999999999978 (-2.2204460492503131e-16)
3601.99999999999999956 (-2.2204460492503131e-16)
3611.99999999999999933 (-2.2204460492503131e-16)
3621.99999999999999911 (-2.2204460492503131e-16)
3631.99999999999999889 (-2.2204460492503131e-16)
3641.99999999999999867 (-2.2204460492503131e-16)
3651.99999999999999845 (-2.2204460492503131e-16)
3661.99999999999999822 (-2.2204460492503131e-16)
3671.99999999999999800 (-2.2204460492503131e-16)
3681.99999999999999778 (-2.2204460492503131e-16)
3691.99999999999999756 (-2.2204460492503131e-16)
370==================
371
372[2, 2.0000000000000102]
3732.00000000000001021
3742.00000000000000977 (-4.4408920985006262e-16)
3752.00000000000000933 (-4.4408920985006262e-16)
3762.00000000000000888 (-4.4408920985006262e-16)
3772.00000000000000844 (-4.4408920985006262e-16)
3782.00000000000000799 (-4.4408920985006262e-16)
3792.00000000000000755 (-4.4408920985006262e-16)
3802.00000000000000711 (-4.4408920985006262e-16)
3812.00000000000000666 (-4.4408920985006262e-16)
3822.00000000000000622 (-4.4408920985006262e-16)
3832.00000000000000577 (-4.4408920985006262e-16)
3842.00000000000000533 (-4.4408920985006262e-16)
3852.00000000000000488 (-4.4408920985006262e-16)
3862.00000000000000444 (-4.4408920985006262e-16)
3872.00000000000000400 (-4.4408920985006262e-16)
3882.00000000000000355 (-4.4408920985006262e-16)
3892.00000000000000311 (-4.4408920985006262e-16)
3902.00000000000000266 (-4.4408920985006262e-16)
3912.00000000000000222 (-4.4408920985006262e-16)
3922.00000000000000178 (-4.4408920985006262e-16)
3932.00000000000000133 (-4.4408920985006262e-16)
3942.00000000000000089 (-4.4408920985006262e-16)
3952.00000000000000044 (-4.4408920985006262e-16)
3962.00000000000000000 (-4.4408920985006262e-16)
3972.00000000000001021 (+1.021405182655144e-14)
398Repeat
3992.00000000000000977 (-4.4408920985006262e-16)
4002.00000000000000933 (-4.4408920985006262e-16)
4012.00000000000000888 (-4.4408920985006262e-16)
4022.00000000000000844 (-4.4408920985006262e-16)
4032.00000000000000799 (-4.4408920985006262e-16)
4042.00000000000000755 (-4.4408920985006262e-16)
4052.00000000000000711 (-4.4408920985006262e-16)
4062.00000000000000666 (-4.4408920985006262e-16)
4072.00000000000000622 (-4.4408920985006262e-16)
4082.00000000000000577 (-4.4408920985006262e-16)
4092.00000000000000533 (-4.4408920985006262e-16)
4102.00000000000000488 (-4.4408920985006262e-16)
4112.00000000000000444 (-4.4408920985006262e-16)
4122.00000000000000400 (-4.4408920985006262e-16)
4132.00000000000000355 (-4.4408920985006262e-16)
4142.00000000000000311 (-4.4408920985006262e-16)
4152.00000000000000266 (-4.4408920985006262e-16)
4162.00000000000000222 (-4.4408920985006262e-16)
4172.00000000000000178 (-4.4408920985006262e-16)
4182.00000000000000133 (-4.4408920985006262e-16)
4192.00000000000000089 (-4.4408920985006262e-16)
4202.00000000000000044 (-4.4408920985006262e-16)
4212.00000000000000000 (-4.4408920985006262e-16)
4222.00000000000001021 (+1.021405182655144e-14)
423Repeat
4242.00000000000000977 (-4.4408920985006262e-16)
4252.00000000000000933 (-4.4408920985006262e-16)
4262.00000000000000888 (-4.4408920985006262e-16)
4272.00000000000000844 (-4.4408920985006262e-16)
4282.00000000000000799 (-4.4408920985006262e-16)
4292.00000000000000755 (-4.4408920985006262e-16)
4302.00000000000000711 (-4.4408920985006262e-16)
4312.00000000000000666 (-4.4408920985006262e-16)
4322.00000000000000622 (-4.4408920985006262e-16)
4332.00000000000000577 (-4.4408920985006262e-16)
4342.00000000000000533 (-4.4408920985006262e-16)
435