This forum is now read-only. Please use our new forums at

Functions, Part I Forum

View Course » View Exercise

239 points
Submitted by
Billy Wood
almost 5 years ago

Math Functions 1 - output of "round(x.xx0xxx)"

Not a question, but a comment:

// Try rounding a floating point number to 3 decimal places
// and print it to the screen
$round_decimal = round(1.2304987026, 3);
echo $round_decimal;

I just noticed that the above gives an output of 1.23 (ie the third decimal place is ignored, rightly, because it is zero). This confused me for a while!

I also felt it unfair that my answer didn't pass, at first, but I would not have learned this little extra lesson otherwise!

1 vote


thanks for the info! Interesting.

274 points
Submitted by
over 4 years ago