Math blocks, rounding even numbers

I'm having difficulty on rounding 143.505 and 302.955 to 2 decimal places using format number math blocks. In excel the result 143.51 and 302.96 while in MIT APP the result is 143.50 and 302.95

App Inventor rounds down. It is not Excel.

round

Returns the given number rounded to the closest integer. If the fractional part is < .5 it will be rounded down. It it is > .5 it will be rounded up. If it is exactly equal to .5, numbers with an even whole part will be rounded down, and numbers with an odd whole part will be rounded up. (This method is called round to even.)

ceiling

Returns the smallest integer that’s greater than or equal to the given number.

floor

Returns the greatest integer that’s less than or equal to the given number.

1 Like

It sounds like OP should use "round".
Oh, nope, nevermind. that rounds to a whole number...
Maybe if you could parse the decimal portion and perform your own rounding function?

thanks ,that's what I've been thinking but I don't know were to start
can you show me how?

thanks I will try that one.


thanks it works :sweat_smile:

1 Like

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