News for hackers. Stuff that matters.
Re:Using signed or unsigned int by default in C (2015) by Asooka on Tuesday August 23, 2022 @03:34PM (#32570220)
The numbers used in computing systems are normal mathematical numbers in the Z_2^32 field. The signed ones are shifted by half the range in the negative direction. There is nothing un-mathematical about them, people who have studied any math in university, i.e. all CS graduates, should have gone through an introductory algebra course that covers fields, rings, etc. So I'm not sure why people keep saying ints are not mathematical.
Re:Using signed or unsigned int by default in C (2015) by mcguire on Tuesday August 23, 2022 @04:11PM (#32570805)
To be honest, I adapted a phrase I usually use for floating point numbers.

But anyway, "So making ints signed makes the most sense otherwise there's an impedance mismatch that you need to explain away" is a pretty poor argument when you're dealing with Z_2^32 (or 2^64) minus 2^31, with some operations becoming partial. (And that's assuming you're on a twos-complement machine; those goofy ones-complement boxes had positive and negative zero.)

Re:Using signed or unsigned int by default in C (2015) by tsimionescu on Tuesday August 23, 2022 @04:05PM (#32570715)
That depends on the computing system. You're right if we're talking about the processor level (on any modern processor), but the "signed ints" in C or C++ are not a field at all, since INT_MAX + 1 is undefined, as are -INT_MIN and INT_MIN - 1 (and many many many multiplications). Also, as someone else was pointing out, unsigned short arithmetic is not well defined either.
Re:Using signed or unsigned int by default in C (2015) by qsort on Tuesday August 23, 2022 @04:51PM (#32571325)
I know what you mean and I'm not saying this with any animus, but this is pretty funny:

> people who have studied any math in university, i.e. all CS graduates, should have gone through an introductory algebra course that covers fields, rings, etc.

> Z_2^32 field