Jump to content
Sign in to follow this  

-n mod m returns -n

Recommended Posts

Is this intended? I'm really bad at math but should it not return a positive remainder? Or are their different mod operators?




Edit: Never Mind, found my answer in the wiki after all:



Be careful when dealing with negative numbers. The way a modulo operation treats negatives differs between languages.

In SQF truncated division is used, hence:

-12 % -10 = -2

-12 % 10 = -2

12 % -10 = 2

12 % 10 = 2



Share this post

Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in

Sign In Now
Sign in to follow this