C++ Logo

sg12

Advanced search

Re: [ub] [c++std-ext-14555] Sized integer types and char bits

From: Lawrence Crowl <Lawrence_at_[hidden]>
Date: Thu, 24 Oct 2013 16:01:30 -0700
On 10/24/13, Xavier Leroy <Xavier.Leroy_at_[hidden]> wrote:
> On 2013-10-24 06:35, Lawrence Crowl wrote:
>> Having said that, my expectation is that programmers that care about
>> [signed integer representation] also care about the size of the integer.
>
> Not necessarily. Consider all the clever arithmetic tricks from the
> book _Hacker's Delight_: most are independent of integer bit-size, but
> most require two's complement representation.

I grant you that the tricks are independent of size. The question is
whether or not an application using those tricks is sensitive to size.

>
>> In that case, int32_t et.al. require a two's complement
>> representation. The programmers that care should use those
>> typedefs.
>
> But they can't because these typedefs are optional.

That's the point, if your algorithm requires two's complement and
uses the typedefs, it will fail to compile. For most folks, that will
be fine.

>> Net result, no change to the standard.
>
> And no improvements for programmers who want to write
> portable code.

It is a help for the vast majority of programmers who do not care
about one's complement machines. Other programmers will need
to work in unsigned arithmetic, then convert to signed.

-- 
Lawrence Crowl

Received on 2013-10-25 01:01:31