1--TEST-- 2Random: Randomizer: getFloat(): Opposite signs are handled correctly 3--FILE-- 4<?php 5 6use Random\Engine; 7use Random\Randomizer; 8 9final class TestEngine implements Engine 10{ 11 private array $values = [ 12 "\x63\xe8\x58\x79\x3e\xf6\x38\x00", 13 "\x64\xe8\x58\x79\x3e\xf6\x38\x00", 14 "\x65\xe8\x58\x79\x3e\xf6\x38\x00", 15 "\x66\xe8\x58\x79\x3e\xf6\x38\x00", 16 "\x67\xe8\x58\x79\x3e\xf6\x38\x00", 17 ]; 18 19 public function generate(): string 20 { 21 return \array_shift($this->values); 22 } 23} 24 25$r = new Randomizer(new TestEngine()); 26 27$min = -1; 28$max = 1; 29printf("%.17g\n", $min); 30printf("%.17g\n\n", $max); 31 32$prev = null; 33for ($i = 0; $i < 5; $i++) { 34 $float = $r->getFloat($min, $max); 35 printf("%.17f", $float); 36 if ($prev !== null) { 37 printf(" (%+.17g)", ($float - $prev)); 38 } 39 printf("\n"); 40 41 $prev = $float; 42} 43?> 44--EXPECT-- 45-1 461 47 48-0.78005908680576086 49-0.78005908680576097 (-1.1102230246251565e-16) 50-0.78005908680576108 (-1.1102230246251565e-16) 51-0.78005908680576119 (-1.1102230246251565e-16) 52-0.78005908680576130 (-1.1102230246251565e-16) 53