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

add "mod" function to FlxMath #3341

Merged
merged 4 commits into from
Jan 28, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions flixel/math/FlxMath.hx
Original file line number Diff line number Diff line change
Expand Up @@ -573,4 +573,13 @@ class FlxMath
{
return (n > 0) ? n : -n;
}

/**
* Returns `a mod b`.
Copy link
Member

@Geokureli Geokureli Jan 23, 2025

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

Copy link
Member

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

*/
public static inline function mod(a:Float, b:Float):Float
{
b = Math.abs(b);
return a - b * Math.floor(a / b);
}
}