I've a piece of Java code from here which converts a number to words, it's working fine but the fraction is always 1 less than it should be, ex. 122.11
is printed 122.10
.
Here is piece of code which is doing the calculation. How can I solve this issue?
String phrase = "122.11" ;
Float num = new Float( phrase ) ;
int dollars = (int)Math.floor( num ) ;
int cent = (int)Math.floor( ( num - dollars ) * 100.0f ) ;