• Post Reply Bookmark Topic Watch Topic
  • New Topic

Rounding technique  RSS feed

 
Greenhorn
Posts: 26
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?)
 
Destroy anything that stands in your way. Except this tiny ad:
Why should you try IntelliJ IDEA ?
https://coderanch.com/wiki/696337/IntelliJ-IDEA
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!