PeCour
June 21, 2023, 8:35am
1
Hi Together,
I have the problem, that since today calculating two numbers does not work anymore
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
Automation.Activities: 23.4.7
System.Activities: 23.4.3
Thank you!
Anil_G
(Anil Gorthi)
June 21, 2023, 8:40am
2
@PeCour
Is the calculation wrong or are you getting any error?
cheers
PeCour
June 21, 2023, 8:42am
3
@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.
Anil_G
(Anil Gorthi)
June 21, 2023, 8:43am
4
@PeCour
Please use Math.Round(value,2)
cheers
1 Like
ppr
(Peter)
June 21, 2023, 8:43am
5
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
Yoichi
(Yoichi)
June 21, 2023, 8:46am
6
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.
Hi,
Itβs Double type accuracy matter.
For now, can you check the following?
[image]
In Double type, 153.9 is precisely 153.90000000000001,
and 153.89+0.01 is preciously 153.89999999999998, because of its accuracy.
We can check it using G specifier.
If we need to prevent this matter, we can use Decimal type.
[image]
The above D is literal for Decimal. Please see the following in details.
Regards,
Regards,
1 Like
PeCour
June 21, 2023, 8:46am
7
@Anil_G ok yes, thank you that was also my workaround
@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.
ppr
(Peter)
June 21, 2023, 8:50am
8
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
system
(system)
Closed
June 24, 2023, 8:50am
9
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.