[SOLVED] Decreasing decimal numbers causes inaccurate results

Hello, friends! :smiley:

In this very old post it is explained that the result that the person who created the topic thought was a bug is actually not a bug: Plus/minus action with decimal numbers in variables

Anyway, how to deal with numbers like that when we need the exact value?
My example:


image

Here I expected 488.1

Thanks!

You can use the ceilTo(<value>, <decimal places>) function in math tools.
Like this: ceilTo(488.099999, 1), which evaluates to 488.1

1 Like

I saw this expression on Wiki but I couldn’t understand and I thought it was not useful in my case :sweat_smile:

Thanks, weadsy1!!! :handshake:

Glad that worked. Yeah for some reason it is super vague, I only figured it out because the syntax of the arguments are similar to how Excel does it, so it was a bit of a lucky guess on my part lol.

1 Like

May you give me an example, and tell me, do you have to do this for each possible number that it does this with?

I’m going to use the example I gave when I opened this topic so you can compare the results. With the expression ceilTo would be:

Events

Debugger
image

Sorry, I don’t know if I understand that question :thinking:, but I’ll try to answer, hehe. In my example I have a calculation, but instead of putting the numbers I could put other variables. Something like this:

Scene Variables

Events

Debugger
image

With this I can change the variables to change my result if I want. And just to clarify the result is 11.9 because I’m using ceilTo, but without it will be:
image

Also, you can go the other way if you prefer if you are using texts to show the results. Using the “Extended Math Support” extension, it will give your project additional math functions to use. One of them is “ToFixedString” which formats a number to use the specified number of decimal places.

Example:

After installed the extension, I used the expression. Notice that I’m using to change the text of my object Text:

I hope my explanation didn’t get confused.