↧
Answer by Eric Postpischil for int and double divided by double java
2.3 is not exactly representable in IEEE-754 64-bit binary floating-point. What happens in your first code sequence is:The source text 2.3 is converted to the nearest representable value,...
View ArticleAnswer by arshajii for int and double divided by double java
double i = o * 100000.0;The value of i after this is 229999.99999999997 (you can see this yourself by adding a simple print statement; it's due to floating-point inaccuracies).int i = (int) (o *...
View ArticleAnswer by Peter Lawrey for int and double divided by double java
There seems to be some IEEE 754 floating point precision specifications I'm missing When you use (int) it truncates the fractional part no matter how close it is to the next whole value. It is not...
View Articleint and double divided by double java
How do I explain the below: double o = 2.3; int i = (int) (o * 100000.0); double d = i / 100000.0; System.out.println(d);prints 2.29999 double o = 2.3; double i = o * 100000.0; double d = i / 100000.0;...
View Article
More Pages to Explore .....