[Logo]
Forums Register Login
Rounding technique
Hi,

1. What is the rounding technique used for Math.round()? I believe it is using HALF-UP rounding (The one we used to learn in elementary school).

2. I know float data type holds 7 significant digits and double holds 16 significant digits. However, when I tested it, the output looks weird.



output:
3.141592653589793 (why double type only outputs 15-significant digits? not 16 significant digits?)
3.1415923 (why is the 7th significant digit 3? What rounding technique does it use?)
3.141593 (why only shows 6-significant digits? not 7?)
If you have a bad day in October, have a slice of banana cream pie. And this tiny ad:
Why should you try IntelliJ IDEA ?
https://coderanch.com/wiki/696337/IntelliJ-IDEA


This thread has been viewed 153 times.

All times above are in ranch (not your local) time.
The current ranch time is
Aug 19, 2018 03:28:50.