motoko
motoko copied to clipboard
issue: Difference between the operator % of Motoko and Smalltalk
I’m porting Smalltalk to Motoko and I’ve found a semantic difference between Motoko’s % operator and the same % operator in Smalltalk. For Motoko’s % operator to return the same result as Smalltalk’s it should, for integers, return a % b = a - (if (a/b > 0) a / b else a/b - 1) * b and for Floats a % b = a - Float.floor(a/b)*b. It seems to me that the definition in Smalltalk is more consistent and coherent than Motoko’s.
https://forum.dfinity.org/t/difference-between-the-operator-of-motoko-and-smalltalk/38822/1