cancel
Showing results for 
Search instead for 
Did you mean: 

Decimal places rounding

Former Member
0 Kudos

Hi Friends,

I have source value coming as 257.565. we need to get the output as 257.57,

When the value is coming as 257.565 in PI we shloud get as 257.57

Kindly do the needful ASAP.

rENU

Accepted Solutions (1)

Accepted Solutions (1)

justin_santhanam
Active Contributor
0 Kudos

Renu,

Try the below UDF.

Single input , and import - java.math.*;



BigDecimal bd  = new BigDecimal(var1).setScale(2, BigDecimal.ROUND_HALF_UP);

return bd.toString();

Former Member
0 Kudos

Thank you so much Raj,Sarvesh ,Satish .... for your quick reponse, Raj code is working perfectly.

Answers (2)

Answers (2)

sunil_singh13
Active Contributor
0 Kudos

Renu,

Use standard function "FormateNum" it rounds the number automatically as per the formate required.

The UDF will not be flexible enough to handle variable lenght of number.

Thanks,

Sunil Singh

Former Member
0 Kudos

>

> Hi Friends,

>

> I have source value coming as 257.565. we need to get the output as 257.57,

>

> When the value is coming as 257.565 in PI we shloud get as 257.57

>

> Kindly do the needful ASAP.

>

> rENU

Have you ever tried the std Arithmetic func to round the values...

If not kindly try them ASAP.

Former Member
0 Kudos

Hi Sarvesh,

I tried to use round standard function . it is roundung to 258.

Kindly guide me

Former Member
0 Kudos

Hi Renu,

Did you try raj function. While creating the udf create the input argument with var1. It will work.

Regards,

---Satish