Skip to content

Concise NearZero function #50

Description

@LeeTeng2001

In math library, the extra branching statement for NearZero function is redundant
Original

	inline bool NearZero(float val, float epsilon = 0.001f)
	{
		if (fabs(val) <= epsilon)
		{
			return true;
		}
		else
		{
			return false;
		}
	}

Suggested:

	inline bool NearZero(float val, float epsilon = 0.001f)
	{
		return fabs(val) <= epsilon);
	}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions