I know this is /c/Progammerhumor, but I wanted to pull on this thread a little bit for my own edification. I’m a Python guy and have been a while, but I’ve dabbled in other languages. The screenshot says “MonoBehaviour” which makes me assume this is mono or a .Net-like language (you know what happens when you assume).
If your player health is a float, would mono or .Net have an issue comparing the float with integer zero “0”? I mean, it seems like floating point precision may make it impossible for it to ever “equal” integer zero, but it also seems like the code isn’t accounting for that precision error.
Floating point errors are a product of how floating points work as a mathematical concept. So they’re independent of the programming language and can happen everywhere.
In this case though, I doubt it’s a critical issue. So the player “died” when they actually had 0.000000000027 hp left or whatever. Who cares? Do you need to be that precise?
I know this is /c/Progammerhumor, but I wanted to pull on this thread a little bit for my own edification. I’m a Python guy and have been a while, but I’ve dabbled in other languages. The screenshot says “MonoBehaviour” which makes me assume this is mono or a .Net-like language (you know what happens when you assume).
If your player health is a float, would mono or .Net have an issue comparing the float with integer zero “0”? I mean, it seems like floating point precision may make it impossible for it to ever “equal” integer zero, but it also seems like the code isn’t accounting for that precision error.
Am I overthinking this?
Floating point errors are a product of how floating points work as a mathematical concept. So they’re independent of the programming language and can happen everywhere.
In this case though, I doubt it’s a critical issue. So the player “died” when they actually had 0.000000000027 hp left or whatever. Who cares? Do you need to be that precise?
Hanging on with 1.70E-31 health.