aspose file tools
The moose likes Java in General and the fly likes difference between two double variables Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "difference between two double variables" Watch "difference between two double variables" New topic
Author

difference between two double variables

rajanikanth bhagavan kanth
Ranch Hand

Joined: May 20, 2008
Posts: 78


it is giving me out put as :: 10.010000000000002 insted of 10.01

May i know why it is giving me like that??

Regards,
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 16811
    
  19


It's a very well known issue with floating point numbers -- the precision of floating point, for certain values, do not represent very well in Base 2, even though they are obvious in Base 10.

This is an issue related to the IEEE floating point standard, which is the standard used by Java, and practically every language and processor used today.


Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
rajanikanth bhagavan kanth
Ranch Hand

Joined: May 20, 2008
Posts: 78
Thnq very much
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: difference between two double variables
 
Similar Threads
Quadratic perplextion
reference to method1 is ambiguous ..... java can't decide whic one to call.
why the code is giving the answer as -1
Another explanation needed
Math.rint() vs. Math.round()