Sunday, December 21, 2014

How to to check decimal part on double?

i would like to know how to get the decimal part of a double. Im trying the following code:



double auxValMin= Double.parseDouble("5.3");
double auxDecimal= auxValMin-floor(auxValMin);
System.out.println(auxDecimal); //I get 0.2999999999999998 instead of 0.3


How can i fix the "0.2999999999999998"?


PS: The code is inside a function.


No comments:

Post a Comment