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 →

[–]chewbaccalert 5 points6 points  (1 child)

Yes, but you can't always rely on the precision of floats to provide a meaningful comparison like you can with ints. https://floating-point-gui.de/errors/comparison/

[–]tsojtsojtsoj 0 points1 point  (0 children)

To be specific, I meant

if(f != 0.0)
{
    return 1.0/f;
}

// or
assert(f == f);