Select to view content in your preferred language

992
2
07-10-2022 04:47 PM
Labels (1)
Emerging Contributor

Hello,

I wrote a very simple expression and used the Round function. The output of the Round function  (i.e. 3.14) is correct, but when I multiply that output by a constant of 10, it is giving me the answer of 31.400000000000002 instead of 31.4. Is there a simple explanation for this? Did I miss something? Thanks!

1 Solution

Accepted Solutions
MVP Esteemed Contributor

It is called "floating point representation" an historic issue well covered.

you might want to round the multiplied value as well.

Python example, which you can emulate in arcade with concatenation

``````"{} vs {}".format(round(math.pi, 2), round(math.pi * 10, 1))
'3.14 vs 31.4'``````

... sort of retired...
2 Replies
MVP Esteemed Contributor

It is called "floating point representation" an historic issue well covered.

you might want to round the multiplied value as well.

Python example, which you can emulate in arcade with concatenation

``````"{} vs {}".format(round(math.pi, 2), round(math.pi * 10, 1))
'3.14 vs 31.4'``````

... sort of retired...
Emerging Contributor

Thank you for the quick reply, Dan!