(C++) signed

February 24, 2017 · View on GitHub

 

 

 

 

 

(C++) signed

 

signed is a keyword that modifies a data type to hold both positive and negative values.

 


int main() {   const int x = 123; //x can contain positive and negative integers }

 

Prefer plain char over signed char and unsigned char [1]. Beware of conversions between signed and unsigned types [2].

 

 

 

 

References

 

  1. Bjarne Stroustrup. The C++ Programming Language (4th edition). 2013. ISBN: 978-0-321-56384-2. Chapter 6.6. Advice. page 169: '[9] Prefer plain char over signed char and unsigned char'
  2. Bjarne Stroustrup. The C++ Programming Language (4th edition). 2013. ISBN: 978-0-321-56384-2. Chapter 6.6. Advice. page 169: '[10] Beware of conversions between signed and unsigned types'