On 24.09.2018 22:15, Vir Campestris wrote:
> On 22/09/2018 13:08, Tim Rentsch wrote:
>> Except for bit-fields, objects are composed of contiguous
>> sequences of one or more bytes, the number, order, and
>> encoding of which are either explicitly specified or
>> implementation-defined.
I almost wrote that in C++ a bit-field is not an object. But it is.
Learned something. :)
> .. which neatly leaves in those odd machines that use a BCD
> representation for their numbers (a byte holds 0-99).
In C++ integers must be represented in pure binary systems, no BCD.
C++17 §6.9.1/3 “The representations of integral types shall define
values by use of a pure binary numeration system.”
However, in C++17 §
21.3.4.1/23 `std::numeric_limits<T>::radix` is
described as “For integer types, specifies the base of the
representation”, with a (non-normative) note, numbered 194,
“Distinguishes types with bases other than 2 (e.g. BCD)”.
For floating point types the same paragraph says that
`std::numeric_limits<T>::radix` just “specifies the base or radix of the
exponent representation (often 2)”. As I understand it this accommodates
decimal arithmetic types where the digits are represented as a single
binary integer. Still I can't quite totally grok it.
Apparently `std::numeric_limits` doesn't support fixed point types, like
a `Currency` type with four fraction part digits?
> Though I haven't seen one in 30 odd years, and not running C, never mind
> C++!
The x86-based processors in our PCs have some rudimentary support for
BCD, but I forget exactly what. :)
Cheers!,
- Alf