I'm not sure how to properly verbalise this issue, but my current project involves a variable called $PlayerHeight and I am having trouble adding sub 1 decimal places to it.
Specifically, say I start with a $PlayerHeight of 6.0 and I want to increase it by 0.1 every time the player enters a particular zone.
For the most part, the player character will turn into 6.1 the first visit and 6.2 on the second.
However, the third visit and onward will leave me with values like 6.2999999999999 and 6.3999999999999.
I've tried testing it with dummy variables, and this occurs across all my game files. I've started with 0 and constantly added 0.1 to it and each time I will eventually land up with something like 0.699999999999.
So, is there anything I can do to keep all my variables at a single decimal place? Or if this is a known issue, is there anyway around it? I've tried searching through the forum and have yet to find anything similar.
Comments
Anyway. You're probably better off using integers here and simply dividing by 10 when printing to get your desired result. For example: Ideally, I'd suggest recording height in inches/centimeters, not feet/meters/whatever, and converting to the appropriate user-friendly form whenever you need to. However, just going with the above example will, at least, get you what you wanted.
Unfortunately the game I'm making requires feet to be used (I'm a metric person myself). However your solution is flawless! Thank you so much! ;D