How to shorten the length of a decimal via rounding?

I want my decimal values to round to a higher decimal, not a whole number.

As far as I know, I have not found a working solution to this.

if anyone can help, this would be awesome.

-- This is how I get the value
(Percentage * MaxValue)

-- This is how I round to get a whole number
math.round(Percentage * MaxValue)

-- I want a decimal to round to 0.25 or 0.50, not a crazy long decimal.

Does something like this help?

local doubleNum = .2938283
print(math.floor((doubleNum * 100))/100)



basically I convert the number into 29.38283, and then I “convert it to an integer” with math.floor, then I divide back by 100 to get the original number

local Number = math.pi
Number = string.format("%.2f", Number)
print(Number) --3.14

You can use the %f format specifier (for floats) with a width (2).