I don't know about the Java printf equivalent, but this function will
return a double with only the specified number of decimal places. You
should be able to modify with a "return bd.toString" or simplify in
some other way to satisfy your needs.
private static double round(double d, int decimalPlace)
{
BigDecimal bd = new BigDecimal(Double.toString(d));
bd = bd.setScale(decimalPlace,BigDecimal.ROUND_HALF_UP);
return bd.doubleValue();
}
On Mar 6, 9:18 am, BobG <[email protected]> wrote:
> What shows: 1.23456789
> What I want: 1.23
> In c it would be printf("%4.2f",n);
> In Java its? (I dont know yet).
> Thanks!
--
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en