Skip to content
New issue

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

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

Already on GitHub? # 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.

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

No branches or pull requests

2 participants