StefanOfMontreal
Programmer
Hello,
I am facing a problem when I try to round
1.8445 to 2 decimal.
Every where they tell you to perform
Math.round(1.8445*100)/100
wich is Math.round(184.45)=184
and 184/100=1.84
well where I went to school they always said that if you
want to round such a number you would start rounding by the end and if you find a 5 or more you would round the next digit.
so in our example since the last digit is a 5, the 4 at the postion 2(from the end) becomes a 5 and then the 4 at positon 3 would also become a 5.
so the result should be
1.85
Does this makes sense or am I becomming completly naze?
P.S. Before posting an answer please TRY your theory.
because numerous ppl would just say
"Well just try Math.round(1.8445)" and this does not work. Just like Math.round(1.49) also gives 1.
So I guess that round does not do rounding properly ?
Thanks for helping
I am facing a problem when I try to round
1.8445 to 2 decimal.
Every where they tell you to perform
Math.round(1.8445*100)/100
wich is Math.round(184.45)=184
and 184/100=1.84
well where I went to school they always said that if you
want to round such a number you would start rounding by the end and if you find a 5 or more you would round the next digit.
so in our example since the last digit is a 5, the 4 at the postion 2(from the end) becomes a 5 and then the 4 at positon 3 would also become a 5.
so the result should be
1.85
Does this makes sense or am I becomming completly naze?
P.S. Before posting an answer please TRY your theory.
because numerous ppl would just say
"Well just try Math.round(1.8445)" and this does not work. Just like Math.round(1.49) also gives 1.
So I guess that round does not do rounding properly ?
Thanks for helping