cancel
Showing results for 
Search instead for 
Did you mean: 

rounding the decimal values in PI

Former Member
0 Kudos

Hi Experts,

In my scenerio i'm obtaining the division values i need to round those values.

In breief,If I'm getting the division value 0.194205 i shoud round it to 0.19421.How can i do this? I have also tried with inbuilt function round but it is rounding the value to integer.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi

Try with function FormatNum.... 000.00000

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi.

It would better don't use Float is better use Bigdecimal.

0 Kudos

Hi,

you can achieve this by writing a UDF, in which you can mention the number of decimals you need. for this you need to import

import java.text.NumberFormat;

float f =Float.parseFloat(a);
NumberFormat num = NumberFormat.getNumberInstance();
num.setMaximumFractionDigits(5);
String str = num.format(i);
return str;

in the above code a is the input argument,

5 is the number of places after the decimal.

Regards

Venkat

former_member187339
Active Contributor
0 Kudos

Hi Divya,

Try this code.

input = String representation of 0.194205


Double dInput = new Double (input);
double d = dInput.doubleValue();
DecimalFormat twoDForm = new DecimalFormat("#.#####");
return Double.valueOf(twoDForm.format(d));

Regards

Suraj

Former Member
0 Kudos

Hi ,

Build in function will not support ,

Try with the UDF

Regards,

Jude