This week's book giveaway is in the Design forum.We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!

# get decimal value

Carl John
Ranch Hand
Posts: 47
i'm having a Float number (i.e) 26.46

i want to get those number(46) after decimal place..

Tom Reilly
Rancher
Posts: 618
One way is to put the float value into an integer value, which removes the fractional part, and then subtract the integer from the float to get the fractional part.

Fiorenza Oppici
Ranch Hand
Posts: 38
this topic may be useful too:
http://www.coderanch.com/t/392641/java/java/decimal-part-float
you could also get it as float rest=number%1.

Rob Spoor
Sheriff
Posts: 20511
54
And then just multiply by 10^(number of digits) and round. So to get 3 digits:
Another way that will always return you all decimals is using Strings:
This will not work, however, if scientific notation (with E, e.g. 4.6E-1) is used. BigDecimal can then help you out, with its toPlainString method.