Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Contributor
Posts: 6
Registered: ‎05-20-2012
My Device: Storm
My Carrier: ATT&T
Accepted Solution

Rounding a Double TO 2 Decimal Places

Can someone please tell me how to round a double when dealing with Blackberry Java?

 

Here is my double:

 

double coneTypeRFAnswer = pi * (BinRadius * BinRadius) * BinHeight;

 

Normally I would just do this:

 

NumberFormat formatDouble =  new DecimalFormat("###,###,###,###.##");

formatDouble(coneTypeRFAnswer);

 

Thanks for the help!  This first bout with Blackberry has definately been a challenge!

Highlighted
Developer
Posts: 226
Registered: ‎10-01-2011
My Device: Passport

Re: Rounding a Double TO 2 Decimal Places

You can use number formatter like this.

 

String s = new Formatter().formatNumber(number, decimals);