Hi! So to make a long story short, I have a global variable that I declared as a float, called "Game_state" and in my main loop, I have a series of if/else statements for what to do depending on what the game_state is set to., and in various other places, the Game_state variable is set to specific values depending on what the user does.
IF game_state = 1
`DO THIS STUFF
else
if Game_state = 1.2
`DO THIS OTHER STUFF
else
if Game_state = 2.5
`DO THIS STUFF HERE
endif
endif
endif
I was having some trouble with certain code not getting executed inside one of these if statements, and I couldnt figure out why. I add a PRINT command to have the program print the current value of Game_state in the top corner so I could see what it was at all times, and to my surprise, when game_state SHOULD be set to 0.41, it was instead displaying as "0.409999996424"
This is very odd, as Game_state is only ever set directly with a "game_state = " and never changed via, like, any math or variables, so the only way it should be able to equal 0.409999996424, is if I explicitly typed in "if CONDITION then Game_state = 0.409999996424" and obviously I know for a fact Ive never done that. I know for a fact that, at the time Im encountering this issue, Ive just done "Game_state = 0.41" so it should just... BE that value. It should be "0.41" and not anything else.
Ive never had this issue before despite having other sections using Game state as 0, 0.1, 0.2, 0.3, 0.21, 0.22, 0.23, 2, 4, 6, 6.4, etc. I cant figure out why 0.41 is an issue and somehow changes itself to be ever so slightly less than that, but 0.21 and 0.22 and such stay their correct values just fine.
Any ideas? Is this just some inherent weirdness of Floats or am I missing something obvious?