Skip to content

Introduce "safe" float comparison  #99

@strangezakary

Description

@strangezakary

Introduce a safe form of comparing floating point. == and != should not be used when comparing floating numbers.

./HandmadeMath.h:854:31: warning: comparing floating point with == or != is unsafe [-Wfloat-equal] hmm_bool Result = (Left.X == Right.X && Left.Y == Right.Y); ~~~~~~ ^ ~~~~~~~ ./HandmadeMath.h:854:52: warning: comparing floating point with == or != is unsafe [-Wfloat-equal] hmm_bool Result = (Left.X == Right.X && Left.Y == Right.Y); ~~~~~~ ^ ~~~~~~~ ./HandmadeMath.h:861:31: warning: comparing floating point with == or != is unsafe [-Wfloat-equal] hmm_bool Result = (Left.X == Right.X && Left.Y == Right.Y && Left.Z == Right.Z); ~~~~~~ ^ ~~~~~~~ ./HandmadeMath.h:861:52: warning: comparing floating point with == or != is unsafe [-Wfloat-equal] hmm_bool Result = (Left.X == Right.X && Left.Y == Right.Y && Left.Z == Right.Z); ~~~~~~ ^ ~~~~~~~ ./HandmadeMath.h:861:73: warning: comparing floating point with == or != is unsafe [-Wfloat-equal] hmm_bool Result = (Left.X == Right.X && Left.Y == Right.Y && Left.Z == Right.Z); ~~~~~~ ^ ~~~~~~~ ./HandmadeMath.h:868:31: warning: comparing floating point with == or != is unsafe [-Wfloat-equal] hmm_bool Result = (Left.X == Right.X && Left.Y == Right.Y && Left.Z == Right.Z && Left.W == Right.W); ~~~~~~ ^ ~~~~~~~ ./HandmadeMath.h:868:52: warning: comparing floating point with == or != is unsafe [-Wfloat-equal] hmm_bool Result = (Left.X == Right.X && Left.Y == Right.Y && Left.Z == Right.Z && Left.W == Right.W); ~~~~~~ ^ ~~~~~~~ ./HandmadeMath.h:868:73: warning: comparing floating point with == or != is unsafe [-Wfloat-equal] hmm_bool Result = (Left.X == Right.X && Left.Y == Right.Y && Left.Z == Right.Z && Left.W == Right.W); ~~~~~~ ^ ~~~~~~~ ./HandmadeMath.h:868:94: warning: comparing floating point with == or != is unsafe [-Wfloat-equal] hmm_bool Result = (Left.X == Right.X && Left.Y == Right.Y && Left.Z == Right.Z && Left.W == Right.W);

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions