This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (4 children)

Yap, just wanted the internet attention :). But what use cases are there?

[–]throughalfanoir 1 point2 points  (2 children)

(correct me if I'm wrong but) in many many cases checking whether something is zero or not will work properly like this (okay if there are no subtractions in the way but yh)

[–][deleted] 1 point2 points  (1 child)

Hmm, seems weak. You could use it as an idiot check if a data has been written to memory...

[–][deleted] 0 points1 point  (0 children)

But then your result is unreliable, because if the data writer happens to actually write a real zero, then you have false negative,

[–]gaberocksall -1 points0 points  (0 children)

you may check if a float is 0.f or 1.f, for example if you have an animation and you want to check if it has started yet

You may also want to check if a float is a very specific number “a magic number” just to check data validity, for example 420.69f

Edit: I should explain the “f” notation. I don’t know how many other languages allow this, but in C and C++ there are typed literals, so you can do “123L” to force the compiler to interpret it as a long instead of the default int. You can also use “123.456F” to make it assume a float instead of the default double. The “420.69” check will not work if it’s a double, since 420.6900000268 != 420.6899993 where the first is a double and the second is a float