+ 3
Manav Roy you can manipulate the number yourself if you want to work around rounding.
Shift the decimal point two places to the right (71316.6), truncate the decimal portion (71316), then shift the decimal point back two places to the left (713.16).
(int)(713.166*100)/100.0
That will force the value from 713.166 to 713.160 and it the output will appear as the unrounded value 713.16.
+ 2
Because it is using the most classical way of rounding floating numbers?
0.6449 = 0.6449 + 0.3551 = 1.0 (rounding up by adding to greater or equal to 0.5)
0.6449 = 0.6449 + 0.0051 = 0.6500 (like your example)
713.166 = 713.166 + 0.004 = 713.17 (your example)
0.4321 = 0.4321 - 0.4321 = 0.0 (rounding up by truncated to less than 0.5)
See also what ceil() and floor() functions do.
0
It rounds to 2 decimal places
0
When we consider about 2 decimal points, the program looks at the third decimal number. If it is equal or greater than 5 the program add 1 to the 2nd decimal otherwise not
0
Here the third decimal is greater than 5. So .16 becomes .17
- 1
Hmm