[android-developers] Re: How do I convert float to 2 decimal places?

2010-08-16 Thread Maps.Huge.Info (Maps API Guru)
Do you want to round or display it as text? Try looking up java.text.DecimalFormat if you want text. -John Coryat -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To

[android-developers] Re: How do I convert float to 2 decimal places?

2010-08-16 Thread Pent
I use, for better or worse, public final static double roundDouble( double d, int places ) { BigDecimal bd = new BigDecimal( Double.toString(d) ); bd = bd.setScale( places, BigDecimal.ROUND_HALF_UP); return bd.doubleValue(); } Pent -- You received this message

[android-developers] Re: How do I convert float to 2 decimal places?

2010-08-16 Thread Robert Nekic
Yeah, I use the NumberFormat: NumberFormat numberFormat = DecimalFormat.getInstance(); numberFormat.setMaximumFractionDigits(2); String formattedText = numberFormat.format(yourFloat); On Aug 16, 11:13 am, Maps.Huge.Info (Maps API Guru) cor...@gmail.com wrote: Do you want to round or display it