Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Why when I type 0.2 in a NumberValue is shows up as 0.20000000000000989?

Asked by 6 years ago
local val = script.Parent
local gui = val.Parent
val.Value = .2

gui.Text = val.Value --the text is .200000999 or somehting like that

val is a NumberValue. Can someone help me please? I need the text or value to be exactly .2

1
It's due how floating point numbers are stored in the memory. I don't think it's possible to circumvent this unless you want to do some stuff such as storing it as a string then using tonumber() to edit it and back using tostring() to store it again. Rheines 661 — 6y
1
You can always round to a certain decimal place, if you know what place you need to round to. User#25115 0 — 6y
1
That can also work. Rheines 661 — 6y
1
I tried using a StringValue and tonumber() and it worked! 0_Halloween 166 — 6y
1
If you're just setting the Text of a GuiButton then you don't need to convert the string value into a number. Rheines 661 — 6y

1 answer

Log in to vote
0
Answered by 5 years ago

I'm a little bit stumped about this. Try 0.02 if you are aiming for that. (0.02 < 0.2 = 0.20 if you dont' know decimal numbers, which i'm pretty sure you do) or 0.20000000000 (the same amount of 0's that was shown on there)

0
please dont listen to me 1 year ago i had no idea what i was saying ScriptsALot 91 — 4y
Ad

Answer this question