"double" problem

edited April 2016 in Questions about Code

Hello everyone!

Shortly, my problem is:

 double JDsl = 2436116.31;
 double     A = JDsl + 0.5;
 println(A);

result is: 2436116.75 ?!?! WHY 0.75 ?! and how do I fix this??

For examle, more examples:

JDsl = 100.31; --> 100.80999755859375 JDsl = 10000.31; --> 10000.8095703125 JDsl = 1000000.31; --> 1000000.8125 JDsl = 2000000.31; --> 1000000.75 JDsl = 5000000.31; --> 5000001.0

I'm confused why like this shows? Does the program is making a mistake? How do I fix this? I'm not an experienced programmer.

BIG THANX!

Answers

Sign In or Register to comment.