Sujet : Re: Top 10 most common hard skills listed on resumes...
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.lang.cDate : 09. Sep 2024, 23:33:16
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20240909152336.398@kylheku.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2024-09-09, David Brown <
david.brown@hesbynett.no> wrote:
On 09/09/2024 20:46, Kaz Kylheku wrote:
On 2024-09-09, David Brown <david.brown@hesbynett.no> wrote:
On 09/09/2024 18:57, Bart wrote:
On 09/09/2024 17:21, Waldek Hebisch wrote:
Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>
C23 doesn't add any new support for 128-bit integers.
>
So what does _Bitint do with a width of 128 bits?
>
>
_BitInt types are not "integer types". Nor is gcc's __int128 type.
How can we write a program which, in an implementation which has a
__int128 type, outputs "yes" if it is an integer type, otherwise "no"?
>
#include <stdio.h>
>
int main() {
auto const x = 0x1'0000'0000'0000'0000;
if (x > 0xffff'ffff'ffff'ffff) {
printf("yes\n");
} else {
printf("no\n");
}
}
If the constant in this program is too wide for any integer type, that
is a constraint violation requiring a diagnostic. After that, if the
program is translated or executed anyway, the behavior is undefined.
I'd like the program to have well-defined behavior, under the
test assumption (that a documented, conforming extension is provided
in the form of __int128).
If the implementation were to truncate the constant to 64 bits, and then
choose a 64 bit type for x, then we would expect the "no" output; but
that doesn't show that there __int128 isn't an integer type, only that
the type is not equipped with constants.
Integer types don't have to have their own matching constants. The types
char and short don't have their own constants; they borrow int.
Library support can be missing, in regard to formatting __int128 to
text and back.
The __int128 type better support all integer arithmetic, though: and
there should be conversion rules regarding when __int128 is opposite to
an operand of a different type. An __int128 should be usable as a
displacement in pointer arithmetic. It should be possible to switch() on
an __int128, even if a constant cannot be expressed for every possible
value.
-- TXR Programming Language: http://nongnu.org/txrCygnal: Cygwin Native Application Library: http://kylheku.com/cygnalMastodon: @Kazinator@mstdn.ca