1--TEST-- 2BcMath\Number round() - has trailing zeros 3--EXTENSIONS-- 4bcmath 5--FILE-- 6<?php 7foreach (RoundingMode::cases() as $mode) { 8 echo "========== {$mode->name} ==========\n"; 9 foreach ([ 10 ['0.00', 1], 11 ['0.1', 5], 12 ['-0.300', 5], 13 ['1.995', 2], 14 ] as [$value, $precision]) { 15 $number = new BcMath\Number($value); 16 $output = 'value is '; 17 $output .= str_pad($value, 6, ' ', STR_PAD_RIGHT) . ', '; 18 $output .= "precision is {$precision}: "; 19 $output .= $number->round($precision, $mode) . "\n"; 20 echo $output; 21 } 22 echo "\n"; 23} 24?> 25--EXPECT-- 26========== HalfAwayFromZero ========== 27value is 0.00 , precision is 1: 0.0 28value is 0.1 , precision is 5: 0.10000 29value is -0.300, precision is 5: -0.30000 30value is 1.995 , precision is 2: 2.00 31 32========== HalfTowardsZero ========== 33value is 0.00 , precision is 1: 0.0 34value is 0.1 , precision is 5: 0.10000 35value is -0.300, precision is 5: -0.30000 36value is 1.995 , precision is 2: 1.99 37 38========== HalfEven ========== 39value is 0.00 , precision is 1: 0.0 40value is 0.1 , precision is 5: 0.10000 41value is -0.300, precision is 5: -0.30000 42value is 1.995 , precision is 2: 2.00 43 44========== HalfOdd ========== 45value is 0.00 , precision is 1: 0.0 46value is 0.1 , precision is 5: 0.10000 47value is -0.300, precision is 5: -0.30000 48value is 1.995 , precision is 2: 1.99 49 50========== TowardsZero ========== 51value is 0.00 , precision is 1: 0.0 52value is 0.1 , precision is 5: 0.10000 53value is -0.300, precision is 5: -0.30000 54value is 1.995 , precision is 2: 1.99 55 56========== AwayFromZero ========== 57value is 0.00 , precision is 1: 0.0 58value is 0.1 , precision is 5: 0.10000 59value is -0.300, precision is 5: -0.30000 60value is 1.995 , precision is 2: 2.00 61 62========== NegativeInfinity ========== 63value is 0.00 , precision is 1: 0.0 64value is 0.1 , precision is 5: 0.10000 65value is -0.300, precision is 5: -0.30000 66value is 1.995 , precision is 2: 1.99 67 68========== PositiveInfinity ========== 69value is 0.00 , precision is 1: 0.0 70value is 0.1 , precision is 5: 0.10000 71value is -0.300, precision is 5: -0.30000 72value is 1.995 , precision is 2: 2.00 73