C++ Logo


Advanced search

Subject: Re: Setting wording for bit manipulation for non-binary hardware
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2021-03-07 03:17:14

On 3/7/21 2:57 AM, Vishal Oza via Std-Discussion wrote:
> The base of this idea is to add an undefined behavior clause if one
> writes C++ using bit manipulation in a target machine that does not use
> binary arithmetic in its arithmetic model. The bits value would
> represent a digit in the numbering system or a q-bit if the system is a
> quantum computing system. The best example I can think of is to have an
> arithmetic unit that has base 10 as its numbering system. We still have
> types like int, long, short, long long,  unsigned int, unsigned long,
> unsigned short, unsigned long long, float and double as well as value
> defined in cstdint but the uint8_t would have value that range from 0 to
> 99999999 while on normal hardware it would range from 0 to 255.

The (u)intN_t types would have to be not defined, as these types are
required to use binary representation, and intN_t are also required to
use two's complement representation. Which is not applicable to your case.

> endian
> would be useful regardless of base as it would describe how the
> processor deals with multi-length words. I am not sure if bit-shifting
> should be defined or not but if it is then the bit shift sure work with
> the hardware base and not assume base-2.

STD-DISCUSSION list run by std-discussion-owner@lists.isocpp.org

Older Archives on Google Groups