Sujet : Re: Integral types and own type definitions (was Re: Suggested method for returning a string from a C program?)
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.lang.cDate : 25. Mar 2025, 09:39:04
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20250325011327.41@kylheku.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2025-03-25, Janis Papanagnou <janis_papanagnou+
ng@hotmail.com> wrote:
On 25.03.2025 05:56, Tim Rentsch wrote:
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
[...]
When I started with "C" or C++ there were not only 8-bit
multiples defined for the integral types; [...]
In C the correct phrase is integer types, not integral types.
>
My apologies if I'm using language independent terms. I'm confident,
though, that most people (obviously you as well) understood the term.
You are 100% correct. You made it clear that you're referring
to a time /when you started with C/. I remember from past discussions
that this was sufficiently long ago that it was ISO C90 or ANSI C,
if not earlier.
In ISO 9899:1990, we have this:
6.1.2.5 Types
[...]
"The type char, the signed and unsigned integer types. and the
enumerated types are collectively called integral types."
^^^^^^^^
The integral types were renamed between C90 and C99. However, "integral
types" remains part of C history. C90 is a still valid, historic and
historically significant dialect of C.
Even today, it is misleading to say that "integral types"
is an incorrect way to talk about C. It's a terminology that
has been formally superseded since C90. However, it is a term
used in computer science and mathematics, and fine for informal
discussions that don't revolve around language-lawyering.
The word has two pronunciations in English. When the emphasis is on the
first syllalble: IN-tgrl, it is a noun which refers to the opposite of a
calculus derivative. The integral of x^2 from 0 to 1, etc.
in-TE-gral is an adjective, which is is a common words---it's an
integral part of everyday English, meaning indivisible from. In math and
CS it is used for indicating that some quantity is in Z.
The C99 and subsquent standards do contain numerous uses of the word
"integral" in that sense:
"The ldexp functions multiply a floating-point number by an integral
power of 2"
"The modf functions break the argument value into integral and
fractional parts"
"When a finite value of real floating type is converted to an integer
type other than _Bool, the fractional part is discarded (i.e., the
value is truncated toward zero). If the value of the integral part
cannot be represented by the integer type, the behavior is
undefined."
I suspect they renamed the integral types to integer types in order
to dissociate the abstract property from the type. The integral
part coming out of modf is not an integer; it is of type double!
-- TXR Programming Language: http://nongnu.org/txrCygnal: Cygwin Native Application Library: http://kylheku.com/cygnalMastodon: @Kazinator@mstdn.ca