Stationeers

Stationeers

View Stats:
Modulus function doesn't work for negative numbers
The modulus of a negative number is a non-negative number, but the math processor returns a negative number when set to modulus.

See example calculation from Wolfram (who knows more math than either of us).
https://www.wolframalpha.com/input/?i=-3+mod+2
< >
Showing 1-1 of 1 comments
ska Nov 14, 2018 @ 12:47pm 
Well, I guess that is not quite exact.

In Programming there is a mathematical variant (here referred as mod), where -3 mod 2 is actually -1.
And there is a symmetric* variant (here referred as div), where -3 div 2 equals 1.

It even gets more confusing, when switching between different programming languages as some of them implement mod (e.g. python) , while others implement div (e.g. java).

So both results are probably correct and just a matter of definition.

*symmetric might be the wrong english term, but i am a non native speaker
< >
Showing 1-1 of 1 comments
Per page: 1530 50

Date Posted: Nov 14, 2018 @ 1:02am
Posts: 1