Convert 418.015 to 418.02

Hi,
I want to get two number after comma. Like that:
418.011-418.01
418.012-418.01
418.013-418.01
418.014-418.01
418.015-418.02
418.016-418.02
418.017-418.02
418.018-418.02
418.019-418.02

Hi @Murat

You can use the Math.Round function, check the below expression,

- Assign -> Input (Double) = 418.011

- Assign -> Output (Double) = Math.Round(Input, 2)

Check the below image for better understanding,

Note : Both Input and Output Variables are in System.Double Datatype.

Hope it helps!!

Hi @Murat

Assign activity:
InputNumber = 418.015

Assign activity:
RoundedNumber = Math.Round(InputNumber + 0.001, 2)

Write Line:
RoundedNumber

Hope it helps!!

Hi,

Can you try the following expression?

Math.Round(dblVar,2,MidpointRounding.AwayFromZero)

image

Regards,

It works for 418.015 but not for 147.015. Why

It seems strange. In my environment. it works well as the following.

image

418 works. Can you try 147.015 ?

Yes, in the above image, input is 417.015.
And also the following expression works.

image

Have you tried 147.015? not 417.015

All right. Probably, it’s double type accuracy matter.
For now, can you try try following expression? This input is 417.015 as Decimal type.

Math.Round(417.015D,2,MidpointRounding.AwayFromZero)

Regards,

@Murat

Sorry, I had misunderstaning regrding input. Can you try the following? This input is 147.015 as Decimal type.

Math.Round(147.015D,2,MidpointRounding.AwayFromZero)

edit: FYI

image

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.