Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

P1236R1 : Why is the c++ standard trying to move away from the word "bit" when defining integers?

According to P1236R1, now integer types are defined with numbers, no longer with bits.

type    minimum range exponent N
signed char     8
short          16
int            16
long           32
long long      64

Instead of defining the meaning of "bit", which the standard is still lacking, C++ chooses not to do that but defines those types in the term of range exponent instead.

Why?
Why is it better not to depend on word "bit"?
What are "unobservable bits" in this proposal?

P1236R1 is part of C++20

like image 283
sandthorn Avatar asked Feb 13 '19 06:02

sandthorn


1 Answers

Under ISO rules, the deliberations of the ISO C++ committee are private and cannot be shared with the programming community at large. The committee has published the following information regarding this matter (issue 1857):

Notes from the June, 2014 meeting:

CWG decided to reformulate the description of the operations themselves to avoid references to bits, splitting off the larger questions of defining “bit” and the like to issue 1943 for further consideration.

Issue 1861 contains similar language.

I was not present at this meeting, but bit has already a definition in ISO/IEC 2382 (which is a normative reference of the C++ standard):

bit

binary digit

either of the digits 0 or 1 when used in the binary system

This definition is clearly inappropriate for many potential uses in the C++ standards, such as talking about a sign bit (which implies a bit at a specific position in a type/word), or the width (in bits) of an integer type.

like image 155
Florian Weimer Avatar answered Nov 15 '22 16:11

Florian Weimer