1--TEST-- 2Feature GH-12143: Extend the maximum precision round can handle by one digit 3--INI-- 4serialize_precisiion=17 5--FILE-- 6<?php 7 8$testCases = [ 9 'PHP_ROUND_HALF_UP' => [ 10 [0.12345678901234565, 16], 11 [-0.12345678901234565, 16], 12 [12345678901234565, -1], 13 [-12345678901234565, -1], 14 [4503599627370495.5, 0], 15 [-4503599627370495.5, 0], 16 ], 17 'PHP_ROUND_HALF_DOWN' => [ 18 [0.12345678901234565, 16], 19 [-0.12345678901234565, 16], 20 [12345678901234565, -1], 21 [-12345678901234565, -1], 22 [4503599627370495.5, 0], 23 [-4503599627370495.5, 0], 24 ], 25 'PHP_ROUND_HALF_EVEN' => [ 26 [0.12345678901234565, 16], 27 [-0.12345678901234565, 16], 28 [12345678901234565, -1], 29 [-12345678901234565, -1], 30 [4503599627370495.5, 0], 31 [-4503599627370495.5, 0], 32 ], 33 'PHP_ROUND_HALF_ODD' => [ 34 [0.12345678901234565, 16], 35 [-0.12345678901234565, 16], 36 [12345678901234565, -1], 37 [-12345678901234565, -1], 38 [4503599627370495.5, 0], 39 [-4503599627370495.5, 0], 40 ], 41 'RoundingMode::AwayFromZero' => [ 42 [0.12345678901234560, 16], 43 [-0.12345678901234560, 16], 44 [12345678901234567, -1], 45 [-12345678901234567, -1], 46 [4503599627370495.5, 0], 47 [-4503599627370495.5, 0], 48 ], 49 'RoundingMode::TowardsZero' => [ 50 [0.12345678901234566, 16], 51 [-0.12345678901234566, 16], 52 [12345678901234565, -1], 53 [-12345678901234565, -1], 54 [4503599627370495.5, 0], 55 [-4503599627370495.5, 0], 56 ], 57 'RoundingMode::PositiveInfinity' => [ 58 [0.12345678901234560, 16], 59 [-0.12345678901234560, 16], 60 [12345678901234564, -1], 61 [-12345678901234564, -1], 62 [4503599627370495.5, 0], 63 [-4503599627370495.5, 0], 64 ], 65 'RoundingMode::NegativeInfinity' => [ 66 [0.12345678901234560, 16], 67 [-0.12345678901234560, 16], 68 [12345678901234564, -1], 69 [-12345678901234564, -1], 70 [4503599627370495.5, 0], 71 [-4503599627370495.5, 0], 72 ], 73]; 74 75foreach ($testCases as $mode => $cases) { 76 echo "========== {$mode} ==========\n"; 77 foreach ($cases as [$val, $precision]) { 78 var_dump(round($val, $precision, constant($mode))); 79 } 80 echo "\n"; 81} 82?> 83--EXPECT-- 84========== PHP_ROUND_HALF_UP ========== 85float(0.1234567890123457) 86float(-0.1234567890123457) 87float(12345678901234570) 88float(-12345678901234570) 89float(4503599627370496) 90float(-4503599627370496) 91 92========== PHP_ROUND_HALF_DOWN ========== 93float(0.1234567890123456) 94float(-0.1234567890123456) 95float(12345678901234560) 96float(-12345678901234560) 97float(4503599627370495) 98float(-4503599627370495) 99 100========== PHP_ROUND_HALF_EVEN ========== 101float(0.1234567890123456) 102float(-0.1234567890123456) 103float(12345678901234560) 104float(-12345678901234560) 105float(4503599627370496) 106float(-4503599627370496) 107 108========== PHP_ROUND_HALF_ODD ========== 109float(0.1234567890123457) 110float(-0.1234567890123457) 111float(12345678901234570) 112float(-12345678901234570) 113float(4503599627370495) 114float(-4503599627370495) 115 116========== RoundingMode::AwayFromZero ========== 117float(0.1234567890123456) 118float(-0.1234567890123456) 119float(12345678901234570) 120float(-12345678901234570) 121float(4503599627370496) 122float(-4503599627370496) 123 124========== RoundingMode::TowardsZero ========== 125float(0.1234567890123456) 126float(-0.1234567890123456) 127float(12345678901234560) 128float(-12345678901234560) 129float(4503599627370495) 130float(-4503599627370495) 131 132========== RoundingMode::PositiveInfinity ========== 133float(0.1234567890123456) 134float(-0.1234567890123456) 135float(12345678901234570) 136float(-12345678901234560) 137float(4503599627370496) 138float(-4503599627370495) 139 140========== RoundingMode::NegativeInfinity ========== 141float(0.1234567890123456) 142float(-0.1234567890123456) 143float(12345678901234560) 144float(-12345678901234570) 145float(4503599627370495) 146float(-4503599627370496) 147