# 0.1 + 0.1 + 0.1 = 0.30000000000000004 issue [SOLVED]

Ok not sure if someone came into this problem but why does 0.1 + 0.1 + 0.1 = 0.30000000000000004 I’ve read articles about programming and seems like it’s an issue that occurs in most programming language

This issue is annoying it screws my rebirth text and gives a non-sense number

Article of the addition explanation :

Why is 0.1 + 0.2 Not Equal to 0.3

2 Likes

I think that is an issue with the Lua interpreter (or whatever it was made on), something you can’t fix.

Can’t you just round the number?

1 Like

Rounding the number would give 2 and it’s not what I want to get because my multiplier value should be as of my system 1.9

1 Like

Round it to the tenths then.​​​​​​​​​​​​​​

How do you do that round function in lua round the nearest decimal digit

1 Like

You could multiply the number by 10 so that it moves one digit to the left. Then, you can round it as an integer and divide by 10 to get your number rounded to the tenths.

``````string.format("%0.1f", x) -- x is your number
``````

https://devforum.roblox.com/t/rounding-numbers/13603

1 Like

Oh shit man that might solve my issue thanks

1 Like

This solved my issue indeed thanks @cakeycocoa

Code of the solution :

``````if #DisciplineValues == 5 then
if DisciplineValues[1] / 10 >= 10 then
_10Divisor = math.floor(DisciplineValues[1] / 10)
print("DIVISOR 10 IS : " .. _10Divisor)

for i = 1, _10Divisor do
Multiplier += 0.1
local formattedString = string.format("%0.1f", Multiplier)
FormatedMultiplier = tonumber(formattedString)

print("MULTIPLIER VALUE IS : " .. FormatedMultiplier)
DEFAULT_REBIRTH_MAX += 10
end

end
end

print("MULTIPLIER VALUE IS : " .. FormatedMultiplier)
print("REBIRTH MAXIMUM VALUE IS : " .. DEFAULT_REBIRTH_MAX)
``````
1 Like

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