Calculating two numbers doesn't work anymore: 1417,63 + 52,24 = 1469.8700000000001

Hi Together,
I have the problem, that since today calculating two numbers does not work anymore :confused:
1417,63 + 52,24 = 1469.8700000000001

I will read both values from a datatable and add them. The values are strings that I convert to doubles.

(convert.TODouble(Betrag) + if(Gesamter_Betrag_Double = β€œβ€,0,convert.ToDouble(Gesamter_Betrag_double))).ToString

image

Automation.Activities: 23.4.7
System.Activities: 23.4.3

Thank you!

@PeCour

Is the calculation wrong or are you getting any error?

cheers

@Anil_G The calculation is wrong, since I get that as answer 1469.8700000000001 but would expect 1469.87. It concerns several projects in UiPath right now, which worked before.

@PeCour

Please use Math.Round(value,2)

cheers

1 Like

it is not wrong or changed. As internally a double can lead to a more detailed fraction it can result to this value. Just use rounding or toString(β€œF2”) on the double result

1 Like

Hi,

I think it’s double type accuracy matter.

I guess you check it in Locals panel as the following.

In double type 1417,63 + 52,24 preciously is 1469.8700000000001 if we display 17 digits.

We can get it using the following expression.

 (1417.63 +52.24).ToString("G17")

The following post may help you.

Regards,

1 Like

@Anil_G ok yes, thank you that was also my workaround :+1:

@ppr ok thanks but I just don’t understand why it worked out for months and now every single double calculation results in these values.

the visual of a number and the internal detail representation can be different
123.4500000000000000000000001 internally is very close to 123.45 and can be triggered by several factors out our control. We just can help the machine e.g. by rounding requests

1 Like

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