Hacker News new | ask | show | jobs
by sjrd 354 days ago
Signed ints are also the integers mod 2^n. The beauty of modular arithmetics is that it's all equivalent. At least for all the operations that work in modular arithmetics in the first place. They just have different canonical representatives for their respective equivalence classes, which are used for the operations that don't work in modular arithmetics (like divisions, comparisons or conversions to string with a sign character).
1 comments

Not in C. In C signed integer overflow is underined behaviour that may or may not be compiled to the equivalent of mod arithmetic dependingonthe whims of the compiler.
C oddities should be relegated to a footnote, not define what computer science is.