C++ Logo

std-proposals

Advanced search

Re: [std-proposals] D3666R0 Bit-precise integers

From: Jan Schultke <janschultke_at_[hidden]>
Date: Tue, 2 Sep 2025 14:14:24 +0200
You seem to be confusing some mostly unrelated concepts.

> > 1. C does not allow _BitInt(1); should C++ to make generic programming
> > more comfortable?
>
> The ring ℤ/2ℤ of integers modulo 2, also a field, is isomorphic to the Boolean ring 𝔹 having exclusive or as addition and logical conjunction as multiplication.
>
> If bool 1+1 is defined to 0, then it is already in C++.

Whether there is some other C++ thing that works mathematically the
same doesn't say anything about whether _BitInt(1) is valid or should
be valid. The issue is regarding a specific type.

> However, in GCC and Clang, bool 1+1 = 1, and I could not see what the standard specifies.

Any nonzero integer is true when converted to bool, so "bool(true +
true)" is essentially "1 + 1 != 0". bool gets promoted to int before
any operation.

Received on 2025-09-02 12:14:39