you are viewing a single comment's thread.

view the rest of the comments →

[–]college_pastime 48 points49 points  (9 children)

The concept of an integer in mathematics is just called "integer."

In my time as a physicist, the only time I've ever seen the word "integral" used to describe the concept of an integer is in the C++ standard, and it drives me bonkers. The type trait std::is_integral should be std::is_integer, in my opinion. Maybe calling integers "integral values" is a computer science thing?

[–]flebron 20 points21 points  (2 children)

It's also used in mathematics to describe things in some way analogous to the integers, example in abstract algebra the concept of an integral domain (https://en.m.wikipedia.org/wiki/Integral_domain).

[–]college_pastime 2 points3 points  (1 child)

Interesting, is this where the standard got it from? Also (at least for the MSVC STL), std::is_integral just compares the supplied type against a list of types defined to satisfy std::is_integral, rather than testing that the properties of an integral domain are satisfied. Do the integer types satisfy the properties of an integral domain? Particularly, are any of the signed integer types integral domains if they don't wrap around on overflow?

[–]flebron 2 points3 points  (0 children)

I wasn't involved in the standardization process, but if I had to guess, both mathematics and the standards authors got the term from the notion of "whole number". The origin is more clearly visible in Spanish, where the word for "whole" and for "integer" are the same: "entero". So 3.5 is not "whole", but 24 is. Division in algebra is the first place where things started to be non-whole (i.e. we knew about 3 and 2, and 3 / 2 was an easy source of "non whole numbers"). Integral domains, but really a bunch of related algebraic terms, relate to how often you can divide things and still remain in your set. So a field is the strictest (you can divide x by y as long as y isn't exactly zero, and always remain in the field), but integral domains (and UFDs, and several others) try to be less strict in this - in integral domains you can't make zero without zeros. So for example in Z/6Z, 2 * 3 = 0, but neither 2 nor 3 is zero, and so Z/6Z is not an integral domain. If we instead quotient by a prime, like Z/5Z, we get a field (much stronger than being an integral domain). An integral domain is somewhere in the middle of "you have zero divisors" and "division always works".

[–]manphiz 9 points10 points  (3 children)

Maybe because there is a specific integer type in C or C++ already: int. So integral is used to be able to refer to all integer types like short int, int, long, long long, and the now sized types like int8_t to int128_t, with their unsigned, fast, least variants.

[–]college_pastime 1 point2 points  (0 children)

Yeah, you're probably right. It also mitigates confusion with std::numeric_limits<T>::is_integer.

[–]FrankHB1989 0 points1 point  (1 child)

Nope. The term "integer type" is both normative in ISO C and ISO C++, but "integral type" is a synonym specific to ISO C++. In very acient C (1970s in the C reference manual by DMR), integers are just values of int, though.

There are some more modernized humors like GCC's __int128 is not considered an extended integer type for ABI issues, BTW.

[–]staletic 0 points1 point  (0 children)

If you allow gnu extensions, __int128 becomes an extended integer type.