Trailing zeros not shown in round()


The round function does not show trailing zeros, leading to failure of the verification for the module!

My original code was as follows, It rounds the answer (9.8696044010894) to three trailing points (9.870) but the output omits the trailing 0 to display (9.87)

echo round (M_PI * M_PI,3);

As a check, I added the following two lines, the only difference being the digit in the third decimal place is changed from a 9 to a 7,

echo round (2.84963,3);

(displays 2.85)

echo round (2.84763,3);

(displays 2.848)

To pass the module, I multiplied the number to be rounded by 10 so that there wasn't a trailing 0, display is now 98.696

echo round (M_PI * M_PI*10,3);

Interestingly, if I change the multiplier to 100, the module would fail again as the displayed answer would be 986.96 as the ....04 would truncate the 4 and then not display the 0.


Hi @terapro22137,

Which module are you talking about there?


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.