cancel
Showing results for 
Search instead for 
Did you mean: 

limiting values upto decimal places.

Former Member
0 Kudos

Hi

I have taken an attribue of type double and on performing some operation the values are coming upto 8 decimal places. I want that it should come only upto 2 decimal places.

Thanks

Saurabh

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Thanks

Former Member
0 Kudos

Hi Saurabh,

Try the below code,



DecimalFormat myDecimalFormat = new DecimalFormat("###.##");
Double formatedNum = Double.parseDouble(myDecimalFormat.format(num));

If num is the resulting double value after some mathametical operation then formatedNum will be its equivalent value with only two decimal places.

Regards,

Vishweshwara P.K.M

former_member218672
Active Contributor
0 Kudos

Hi Saurabh,

you should use round off functionality of java like Round(num,2)

Regards,

Sen

Former Member
0 Kudos

Hi

plz xplain it with example

Thanks

nikhil_bose
Active Contributor
0 Kudos

create a Simple Data type in dictionary as float, use 'Representation' as "###.00" and use this simple type as the attribute type. This would give the desired output.

Regards,

Nikhil Bose