c - When uses unsigned data type? -
this question has answer here:
- signed versus unsigned integers 15 answers
when need use unsigned data type , when signed data type in c? , want know why , how decide 1 need.
use signed data types when need variable hold negative values. careful overflows, signed integer overflows result in undefined behavior.
use unsigned data types when know variable holds non-negative values, or bit patterns. generally, can hold higher maximum value signed data type of equal size. unsigned integer overflows wraparound.
Comments
Post a Comment