locking float precision
dbokser
Member Posts: 8
Is there a way to specify how many decimal places I want a float to display? In my game, I'm keeping score with money. Whenever the character gets more money, I'm using an Interpolate to increment the money visually so it doesn't just pop into the new value. The problem arises that it starts to display 4 or 5 decimal places on the interpolation instead of the 2 that money has. I tried making the money an integer and then upon display dividing by 100.0 but it just converts the value back into a float and displays the 5 decimal places. Any suggestions on this?
Comments
As for your issue, are you able to simplify the money collected into pennies?
So every time the player picks up something worth money,
it adds to their totalPennies count?
(or subtracts from it if they do something incorrectly)
If so, it would be much easier to work with.
And you could display it as dollars and cents like this:
game.totalPennies = 2439
Display Text
"$"..floor(game.totalPennies/100).."."..game.totalPennies%100
That would display as: $24.39
Hope this helps!
Joe