I'm working on some function that rounds a number to specific decimal places, and I want to ask; what if we have an output that has decimal places less than required. e.g. "$1.002$" rounded to two decimal places, will be "$1$" or "$1.00$" and also "$0$" (zero) rounded to two decimal places, will be "$0$" or "$0.00$". thanks :)
Asked
Active
Viewed 2,182 times
0
-
1.00 and 0.00.. – JRN Dec 17 '17 at 08:47
-
@Haytham Mahmoud If you are ok, you can set as solved. Thanks! – user Dec 18 '17 at 13:29
1 Answers
0
Usually the following rule is adopted:
consider: $N=1.00abcd...$
set: $X=(N-1)1000=a.bcd...$
$N$ rounded to two decimal places is
- 1.00 if $0\leq X <5$
- 1.01 if $X\geq5$
EG
$$1.006347 \to 1.01$$ $$1.005012 \to 1.01$$ $$1.004912 \to 1.00$$
user
- 154,566