Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does the C++ standard require a binary machine?

I find in the standard:

The representations of integral types shall define values by use of a pure binary numeration system

But my understanding is that this is not a requirement that C++ must be implemented on machines that are based on base 2 in hardware; in other words, this seems to be only a requirement for what the programmer shall see.

Does the C++ standard require a binary CPU, or could a valid C++ implementation be implemented on ternary or decimal machines?


tiny background info: in history, there have already been computers with decimals, ternaries, or computers where a C++byte would be 36 bits long (PDP-10)

like image 294
Sebastian Mach Avatar asked Oct 10 '12 15:10

Sebastian Mach


1 Answers

Although never directly stated in the standard, there's an "as if" rule that applies to essentially all requirements in the C++ (and C) standard.

In other words, you're allowed to break any rule you want to, as long as you produce the same externally observable effects as if you'd followed the rule as stated. Although not stated in the standards themselves, this rule is explicitly stated in the Rationale for the C standard. As far as I know, there's no matching rationale for the C++ standard, but the two are closely enough related that I see little problem in applying the rule to both.

like image 107
Jerry Coffin Avatar answered Sep 30 '22 18:09

Jerry Coffin