The modulo operation is defined as a mathematical operation modulo:
Mathematical operations such as addition, subtraction, negation, multiplication, division, and mathematical functions defined later in this section should always be understood as calculating exact mathematical results from mathematical real numbers that do not include infinity and do not include a negative zero, which is equal to different from positive zero.
Your question:
ToInt32 (-1) is equal to ToInt32 (1)
Oh no:
Let posInt be the sign (number) * gender (abs (number)).
posInt = sign(-1) * floor(abs(-1)) = -1;
Let int32bit be posInt modulo 2 32 ; those. the final integer k is a type of positive signed number and less than 2 32 in magnitude such that the mathematical difference between posInt and k is a mathematical integer multiple of 2 32 .
int32bit = posInt mod 4294967296 = -1 mod 4294967296 = 4294967295
( wolfram alpha link for math result )
If int32bit is greater than or equal to 2 31, return int32bit - 2 32 otherwise return int32bit.
Since 4294967295 >= 2147483648 , we return 4294967295 - 4294967296 , IE -1 .
If we ToInt32(1) the same steps for ToInt32(1) , we get 1 . Thus, they do not have the same result.
source share