How to round decimals and leave only hundredths?

Hi Developers! :wave:
So recently I’ve encountered a problem with rounding numbers to 2 digits afterr decimal point. Like if I want to make a KDR system these decimals will matter, but I don’t want infinite decimal like 7.33333… to be present.

Are there any solutions to this issue? I’d be glad for any help provided! :hidere:

If you want to display it in text, you could use string.format, like so:

string.format("%.2f", VALUE)

image
(2 specifies the number of decimals. Note that this forces the number of decimals, so you may see things like 5.00)

Alternatively, if you want it as a number, you can do something like this:

math.round(VALUE * 100) / 100

image

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.