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

isApproxEqual could be moved to dot/Util? #410

Closed
jessegreenberg opened this issue Mar 7, 2018 · 2 comments
Closed

isApproxEqual could be moved to dot/Util? #410

jessegreenberg opened this issue Mar 7, 2018 · 2 comments
Assignees

Comments

@jessegreenberg
Copy link
Contributor

  /**
   * Determine if two numbers are within tolerance of each other
   * @param {number} a
   * @param {number} b
   * @param {number} tolerance
   * @returns {boolean}
   */
  function isApproxEqual( a, b, tolerance ) { return Math.abs( a - b ) <= tolerance; }

This seems like it could be generally useful. For #398.

@jessegreenberg
Copy link
Contributor Author

On slack:

Jesse Greenberg [6:10 PM]
EnergySkateParkBasicsModel has an `isApproxEqual` function that returns true if two values are equal within a tolerance. Seems generally useful, and I would move it to dot/Util. Others OK with this?


Jonathan Olson [6:13 PM]
hah, I have equalsEpsilon as a function on most dot types, but don't have it for basic numbers. Feel free to add it

Jesse Greenberg [6:14 PM]
Cool, call it equalsEpsilon in Util?

Jonathan Olson [6:15 PM]
Sure, sounds good. (Should we rename them in general to isApproxEquals? Might be easier to find/understand)

Jesse Greenberg [6:17 PM]
I don't think it is worth a rename, my first search would be "equal" and I would fine equalsEpsilon that way

Ill add it to Util.

@jessegreenberg
Copy link
Contributor Author

Done with the above commits.

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

No branches or pull requests

1 participant