1--TEST-- 2Fix GH-12143: Optimize round 3--FILE-- 4<?php 5echo "HALF_UP\n"; 6var_dump(round(1.700000000000145, 13, PHP_ROUND_HALF_UP)); 7var_dump(round(-1.700000000000145, 13, PHP_ROUND_HALF_UP)); 8var_dump(round(123456789012344.5, -1, PHP_ROUND_HALF_UP)); 9var_dump(round(-123456789012344.5, -1, PHP_ROUND_HALF_UP)); 10echo "\n"; 11 12echo "HALF_DOWN\n"; 13var_dump(round(1.70000000000015, 13, PHP_ROUND_HALF_DOWN)); 14var_dump(round(-1.70000000000015, 13, PHP_ROUND_HALF_DOWN)); 15var_dump(round(123456789012345.0, -1, PHP_ROUND_HALF_DOWN)); 16var_dump(round(-123456789012345.0, -1, PHP_ROUND_HALF_DOWN)); 17var_dump(round(1.500000000000001, 0, PHP_ROUND_HALF_DOWN)); 18var_dump(round(-1.500000000000001, 0, PHP_ROUND_HALF_DOWN)); 19echo "\n"; 20 21echo "HALF_EVEN\n"; 22var_dump(round(1.70000000000025, 13, PHP_ROUND_HALF_EVEN)); 23var_dump(round(-1.70000000000025, 13, PHP_ROUND_HALF_EVEN)); 24var_dump(round(1.70000000000075, 13, PHP_ROUND_HALF_EVEN)); 25var_dump(round(-1.70000000000075, 13, PHP_ROUND_HALF_EVEN)); 26var_dump(round(12345678901234.5, 0, PHP_ROUND_HALF_EVEN)); 27var_dump(round(-12345678901234.5, 0, PHP_ROUND_HALF_EVEN)); 28var_dump(round(1.500000000000001, 0, PHP_ROUND_HALF_EVEN)); 29var_dump(round(-1.500000000000001, 0, PHP_ROUND_HALF_EVEN)); 30echo "\n"; 31 32echo "HALF_ODD\n"; 33var_dump(round(1.70000000000025, 13, PHP_ROUND_HALF_ODD)); 34var_dump(round(-1.70000000000025, 13, PHP_ROUND_HALF_ODD)); 35var_dump(round(1.70000000000075, 13, PHP_ROUND_HALF_ODD)); 36var_dump(round(-1.70000000000075, 13, PHP_ROUND_HALF_ODD)); 37var_dump(round(12345678901233.5, 0, PHP_ROUND_HALF_ODD)); 38var_dump(round(-12345678901233.5, 0, PHP_ROUND_HALF_ODD)); 39var_dump(round(1.500000000000001, 0, PHP_ROUND_HALF_ODD)); 40var_dump(round(-1.500000000000001, 0, PHP_ROUND_HALF_ODD)); 41?> 42--EXPECT-- 43HALF_UP 44float(1.7000000000001) 45float(-1.7000000000001) 46float(123456789012340) 47float(-123456789012340) 48 49HALF_DOWN 50float(1.7000000000001) 51float(-1.7000000000001) 52float(123456789012340) 53float(-123456789012340) 54float(2) 55float(-2) 56 57HALF_EVEN 58float(1.7000000000002) 59float(-1.7000000000002) 60float(1.7000000000008) 61float(-1.7000000000008) 62float(12345678901234) 63float(-12345678901234) 64float(2) 65float(-2) 66 67HALF_ODD 68float(1.7000000000003) 69float(-1.7000000000003) 70float(1.7000000000007) 71float(-1.7000000000007) 72float(12345678901233) 73float(-12345678901233) 74float(2) 75float(-2) 76