Unsigned keyword in C++

后端 未结 5 1569
醉酒成梦
醉酒成梦 2020-12-02 08:38

Does the unsigned keyword default to a specific data type in C++? I am trying to write a function for a class for the prototype:

unsigned Rotate(unsigned ob         


        
5条回答
  •  爱一瞬间的悲伤
    2020-12-02 09:11

    You can read about the keyword unsigned in the C++ Reference.

    There are two different types in this matter, signed and un-signed. The default for integers is signed which means that they can have negative values.

    On a 32-bit system an integer is 32 Bit which means it can contain a value of ~4 billion.

    And when it is signed, this means you need to split it, leaving -2 billion to +2 billion.

    When it is unsigned however the value cannot contain any negative numbers, so for integers this would mean 0 to +4 billion.

    There is a bit more informationa bout this on Wikipedia.

提交回复
热议问题