Difference between revisions of "Operator Reference"

No change in size ,  16:37, 24 June 2018
m
→‎Note: Made the first sentence easier to read by swapping the order of the hexadecimal and decimal example values.
imported>Homecom
m (→‎Note: Ceased referring to 0x80000001 as a "large negative integer", because it is, in fact, almost the smallest negative value that can be stored in a 32-bit two's-complement integer.)
imported>Homecom
m (→‎Note: Made the first sentence easier to read by swapping the order of the hexadecimal and decimal example values.)
 
Line 69: Line 69:
=== Note ===
=== Note ===


In the past, there was concern about the correctness of the [https://en.wikipedia.org/wiki/Modulo_operation modulo] (<code>%</code>) operator when applied to negative integers such as 0x80000001 (-2,147,483,647). Those concerns were unfounded.  
In the past, there was concern about the correctness of the [https://en.wikipedia.org/wiki/Modulo_operation modulo] (<code>%</code>) operator when applied to negative integers such as -2,147,483,647 (0x80000001). Those concerns were unfounded.  


''The modulo operator produces correct results in all cases'', but it must be understood that the result will have the sign of the dividend in Papyrus (as in Java and many other languages), therefore <code>3 % 2 == 1</code> and <code>-3 % 2 == -1</code>.
''The modulo operator produces correct results in all cases'', but it must be understood that the result will have the sign of the dividend in Papyrus (as in Java and many other languages), therefore <code>3 % 2 == 1</code> and <code>-3 % 2 == -1</code>.
Anonymous user