News for hackers. Stuff that matters.
Re:Most ints are not floats by munchler on Sunday June 29, 2025 @03:44PM (#44415768)
True, but we also have to be careful about teaching ints as the computer version of integers.
Re:Most ints are not floats by jrvieira on Sunday June 29, 2025 @04:10PM (#44416007)
wait, why?
Re:Most ints are not floats by neepi on Sunday June 29, 2025 @04:12PM (#44416018)
Proper integers aren’t bounded. Computer ints are.
Re:Most ints are not floats by jrvieira on Sunday June 29, 2025 @06:06PM (#44416945)
Unbounded integer types exist, which have infinite precision in theory and are only limited by available memory in practice.

You can make the argument that "proper" integers are also bounded in practice by limitations of our universe :)

Re:Most ints are not floats by layer8 on Sunday June 29, 2025 @07:09PM (#44417466)
Unbounded integer types aren't ints.

The important point is that the arithmetic operators on int perform modulo arithmetics, not the normal arithmetics you would expect on unbounded integers. This is often not explained when first teaching ints.

Re:Most ints are not floats by adastra22 on Sunday June 29, 2025 @11:25PM (#44419003)
In many langue’s (e.g. Python, so not even obscure languages), ints are unbounded.
Re:Most ints are not floats by layer8 on Monday June 30, 2025 @01:26AM (#44419734)
That’s not the notion of ints the article, nor GP by “computer ints”, was referring to. Python is rather atypical in its nomenclature here. Arbitrary-precision integers are generally called “integer” or something like “bigint”.
Re:Most ints are not floats by MathMonkeyMan on Sunday June 29, 2025 @04:33PM (#44416209)
Unsigned ints are the non-negative integers mod 2^n.

Signed ints behave like the integers in some tiny subset of representable values. Maybe it's something like the interval (-sqrt(INT_MAX), sqrt(INT_MAX)).

Re:Most ints are not floats by sjrd on Sunday June 29, 2025 @05:25PM (#44416558)
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).
Re:Most ints are not floats by SkeuomorphicBee on Sunday June 29, 2025 @06:55PM (#44417366)
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.
Re:Most ints are not floats by adastra22 on Sunday June 29, 2025 @11:24PM (#44418997)
C oddities should be relegated to a footnote, not define what computer science is.
Re:Most ints are not floats by AlotOfReading on Sunday June 29, 2025 @05:19PM (#44416517)
That's one way of looking at them. You can also look at the signed integers as bounded 2-adic numbers.
Re:Most ints are not floats by LegionMammal978 on Sunday June 29, 2025 @05:45PM (#44416738)
"Bounded 2-adic integers" would only make sense if you were bounding the 2-adic norm. Integers mod 2^n would be closer to "approximate fixed-point 2-adic integers".

(Alas, most languages don't expose a convenient multiplicative inverse for their integer types, and it's a PITA to write a good implementation of the extended Euclidean algorithm every time.)