0

my question is related to data types that why when we declare a signed data type as unsigned it then only prefer positive values to store in it and not negative why positive was preferred and negative was ignored in this case why it should not prefer negative values in unsigned situation I tried to assign negative values but error occurs and I want to know what is the logic behind it.

  • 3
    possible duplicate of [What is the difference between signed and unsigned int](https://stackoverflow.com/questions/5739888/what-is-the-difference-between-signed-and-unsigned-int) – oRole Oct 01 '17 at 17:40
  • 2
    Possible duplicate of [What is the difference between signed and unsigned int](https://stackoverflow.com/questions/5739888/what-is-the-difference-between-signed-and-unsigned-int) –  Oct 01 '17 at 17:59
  • When you make a cast of signed int to unsigned int, it simply leaves intact the integer value. For positive integers this does not change and for the negative, you get the 2's complement since negative integers are stored in this form. – Jean-Claude Colette Oct 01 '17 at 18:06

0 Answers0