How to determine integer types that are twice the width as `int` and `unsigned`?

后端 未结 2 794
眼角桃花
眼角桃花 2020-12-02 01:58

Values of intermediate multiplication typically need twice the number of bits as inputs.

 // Example
int foo(int a, int b, int carry, int rem) {
  int2x c;           


        
2条回答
  •  独厮守ぢ
    2020-12-02 02:38

    The assumption that all *_MAX constants are of the form (2^n)-1 is valid. See 6.2.6 Representations of Types, and particularly 6.2.6.2 Integer types, where the representations of unsigned integer types and the positive values of signed integer types are fully defined as pure binary, thus yielding a maximum which is one less than a power of two.

提交回复
热议问题