Hey,
Can someone exmplain me how this works?
{{ 10472.78 * 100 }} i get 1047278.0000000001
Hi @ConstantineK Welcome!
Let me clarify ![]()
This is a programming issue basically javascript’s float data type precision, just use {{ (10472.78 * 100).round(2) }} to fix this.
(I saw your issue earlier) So cheers!
Just to add a small detail that might help: in n8n expressions we’re effectively working with standard JavaScript, so methods like Math.round() are usually the safest way to handle this kind of rounding.
For example, you could use: {{ Math.round(10472.78 * 100) }}
This should give you a clean integer result without the extra decimals.
This is normal behavior it’s due to how JavaScript handles decimal numbers.
In JavaScript (which n8n uses), some decimal values can’t be represented exactly in binary. So when you do calculations like:
10472.78 * 100
you may get:
1047278.0000000001
instead of exactly:
1047278
Just round the result:
{{ Math.round(10472.78 * 100) }}
or if you want to keep decimals:
{{ (10472.78 * 100).toFixed(2) }}
It’s not an error just floating point precision. Rounding the result will give you the correct value
Edit: @tamy.santos @akingbade-Samuel giving the exact same answer again is not helpful.
Hi @bartv
Thanks for the feedback. My intention was not to repeat the same answer unnecessarily.
In standard JavaScript, .round(2) is not a valid Number method, so I wanted to clarify the solution using Math.round(…), which is the standard JavaScript approach here.
My goal was simply to add a technically accurate clarification and be helpful to the community.
Hello @tamy.santos for clarification purposes, I did request .round(2) beforehand
(10472.78 * 100).round(2)
Your comment about “.round(2) not being valid JavaScript” may be correct in isolation but does not address the problem. It is just offering a syntactical correction, not a meaningful solution.
In addition, the main problem (floating-point precision) and the practical fix (rounding/formatting) were already mentioned before your reply. In the view of @bartv, it seems so in the sense that it repeats itself rather than elaborates.
Okay, so I’m removing the duplication part and leaving only the technical correction.
Hey Guys,
i understand how 01 binary works, and thank you for the solutions, i already using round math.
i just dont understand why in set node you are not using simple math, but js
for me its the same if i would do this in excel and get 1047278.0000000001 ![]()
thank you all
@ConstantineK
Because the Set node uses expressions, and in n8n expressions are JavaScript-based. So even for simple math, the expected approach is to use a JS expression like {{ $json.a + $json.b }}. If the logic gets more complex, that’s usually when I’d move it to a Code node.
Yes exactly that’s a great way to handle it.
Since n8n expressions use standard JavaScript, floating point precision can cause those small decimal issues, so using Math.round() is the safest approach for clean results.
Your example works perfectly:
{{ Math.round(10472.78 * 100) }}
This ensures you always get a proper integer without unexpected decimals.