Rounding Decimals to whole numbers
Posted
by
USDblades
on Stack Overflow
See other posts from Stack Overflow
or by USDblades
Published on 2011-01-02T02:48:35Z
Indexed on
2011/01/02
2:53 UTC
Read the original article
Hit count: 298
I was looking around and could not find exactly what I was looking for.
I want to round all my numbers up to the whole number.
Example:
5.9 would be 6
5.5 would be 6
5.1 would be 6
5.000001122 would be 6
5.0 would be 5
I was thinking if I put them into ints that would get rid of the decimal but it did not look right as the decimals were just dropping off. Am I correct here?
So I thought about just doing that then adding 1 to the final result which would fix about 99% of the problem but if my result is 5 I do not want to add 1 to it.
How would I go about fixing this issue I have?
© Stack Overflow or respective owner