Sorry about the title. It’s hard to explain this in a sentence. I’ll just give an example.
Is there a way I can get the intended output of: 0.05 and 0.3?
local firstDecimal = 0.05
local secondDecimal = 0.3
local str = string.format("%f and %f", firstDecimal, secondDecimal)
--Intended output of: 0.05 and 0.3
so let’s say we only want 2 decimal place with 0.056
both methods we times the number by 100 which would 0.056 * 100 = 5.6
now here is where both methods are different
math.floor(5.6) = 5
math.round(5.6) = 6
now we divid by 100
5 / 100 = 0.05
6 / 100 = 0.06
so what have we learned here?
use math.floor if you want to completely remove the other decimal places
and use math.round if you want to remove the decimal places but also have the decimal rounded(example: 0.056 rounded to the hundredths place is 0.06)
my main point here is that both methods have their use cases, your way or my way are both the right ways to do it
They’re used for precision. 0.2 tells the program that I want it to format the string using two decimals of precision, while the 0.1 tells it that I only want one decimal of precision.
Oh that makes a lot of sense. Thats what I assumed at first, but when saw the variable firstDecimal and thought that was suppose to be something like .5 and the secondDecimal as .03 because of the variable names. but in the op its the other way around. Thanks!