-
Notifications
You must be signed in to change notification settings - Fork 454
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
add "mod" function to FlxMath #3341
base: dev
Are you sure you want to change the base?
Conversation
flixel/math/FlxMath.hx
Outdated
@@ -573,4 +573,13 @@ class FlxMath | |||
{ | |||
return (n > 0) ? n : -n; | |||
} | |||
|
|||
/** | |||
* Returns `a mod b`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The doc should explain what "mod" is, the difference between this and haxe's %
operator and give at least one key example of that difference
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also we should add that example and others to the unit test
@@ -575,7 +575,15 @@ class FlxMath | |||
} | |||
|
|||
/** | |||
* Returns `a mod b`. | |||
* Performs a modulo operation on two numbers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about?
* Performs a modulo operation on two numbers. | |
* Performs a modulo operation to calculate the remainder of `a` divided by `b` |
I want it to actually say what modulo/mod is
this pr adds a more "mathematically accurate" alternative to the built-in modulo operator to
FlxMath
as a helper functionhaxe
a % b
behavior (truncated division):By Mathnerd314159 - Own work based on: Divmod.svg by Salix alba, CC BY-SA 3.0, Link
a mod b
behavior (euclidean division):By Mathnerd314159 - Own work based on: Divmod.svg by Salix alba, CC BY-SA 3.0, Link