Float to string: It's not playing nice

I’m trying to store floats as strings, but using tostring spits out abominations like this:
0.10000000149012 :sob:
Admittedly I don’t have a full grasp on how floats work, but from what I gather, these horrid numbers are the result of simpler components being divided or something along those lines. If I could get a hold of those simpler components maybe I could store those instead thus making the strings shorter? Or maybe there’s a built-in, simpler notation for these numbers? I’ve been digging around the API but haven’t found any solutions yet.

1 Like
SomeCrazyNumber = 1.123456789
MyNiceString = string.format("%.1f", SomeCrazyNumber)
--change the .1 to something else if you want
2 Likes