Skip to main content

Why do decimal calculations produce unexpected rounding results in my app?

Decimal math operations in Bubble may produce small rounding errors due to how computers represent decimal numbers in binary floating-point. This can affect the ":rounded to" operator.

Written by Sofia Maconi

When your app performs math that results in a decimal number, the stored value may not be exactly what you'd expect. This is a fundamental limitation of how computers represent decimal numbers using binary floating-point arithmetic — certain decimals can't be stored with perfect precision, which causes small rounding errors.

What you might notice

  • A calculation that should produce a specific decimal produces a slightly different result

  • The ":rounded to" operator doesn't always round as expected — for example, "2100.055 rounded to 2" may return "2100.05" instead of "2100.06"

  • Results vary slightly from what a standard calculator would show

Workaround

For specific use cases, consider working in whole numbers and converting at the point of display — for example, storing a price in cents rather than dollars, then dividing by 100 when you display it. This reduces the number of decimal operations and minimises the risk of rounding errors accumulating.

Did this answer your question?