News for hackers. Stuff that matters.
Re:Almost Always Unsigned by kazinator on Sunday January 02, 2022 @11:28AM (#29770082)
Unsigned means "modular arithmetic with a modulus that you do not choose and that is implementation-defined unless you have pinned down the bit width of the unsigned type, and that has implicit conversions from signed types that drastically alter the value".

Note that when mathematicians work in the area of congruences, they do not use unsigned integers.

For instance, when we look at Euler's Theorem:

https://en.wikipedia.org/wiki/Euler%27s_theorem

all the quantities in the formula can be understood as just integers, not unsigned integers.

The exponentiation of a can be understood as regular exponentiation. The modularity plays out in the triple-equal-sign operator and the (mod n) parenthetical part which says that the two sides of the equation are equivalent in a particular way.

The left side of the equation uses ordinary exponentiation and can produce values >= n; it is not wrapped.

It's crystal clear that we cannot replace the triple equal sign with the regular one, and drop the (mod n).

Re:Almost Always Unsigned by SAI_Peregrinus on Sunday January 02, 2022 @01:55PM (#29772205)
They also don't use signed integers, in the sense that computer languages use the term. Signed integers are also bounded in extent, and for most systems wrap on over/underflow. Euler's Theorem doesn't hold for them any more than it does for unsigned integers.

Don't treat computer "integers" like mathematical integers. It leads to pain. They're members of a few finite fields.