Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concise NearZero function #50

Open
LeeTeng2001 opened this issue Mar 12, 2022 · 1 comment
Open

Concise NearZero function #50

LeeTeng2001 opened this issue Mar 12, 2022 · 1 comment

Comments

@LeeTeng2001
Copy link

LeeTeng2001 commented Mar 12, 2022

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);
	}
@chalonverse
Copy link
Contributor

Yes, that is a good point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants