Storing and printing 10+ digit integer in c++

后端 未结 8 1715
北荒
北荒 2020-12-21 14:39

I\'m using cout to print digits to the console. I am also storing values of up to 13+billion as a digit and doing computations on it. What data type should I use?

Wh

8条回答
  •  太阳男子
    2020-12-21 15:37

    It's a good idea to understand the range limits of different sized types.

    A 32 bit type (on most 32 bit platforms, both int and long are 32 bit) have the following ranges:

    signed: -2,147,483,648 to 2,147,483,647
    unsigned: 0 to 4,294,967,295
    

    While 64 bit types (typically long long's are 64 bit, on most Unix 64 bit platforms a long is also 64) have the following range:

    signed: -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
    unsigned: 0 to 18,446,744,073,709,551,615
    

提交回复
热议问题