What's the difference in int(11)
and int(11) UNSIGNED
?
The XDR standard defines signed integers as integer. A signed integer is a 32-bit datum that encodes an integer in the range [-2147483648 to 2147483647]. An unsigned integer is a 32-bit datum that encodes a nonnegative integer in the range [0 to 4294967295].
An int is signed by default, meaning it can represent both positive and negative values. An unsigned is an integer that can never be negative.
There is no difference. unsigned and unsigned int are both synonyms for the same type (the unsigned version of the int type).
Unsigned integers are used when we know that the value that we are storing will always be non-negative (zero or positive).
An UNSIGNED type cannot be negative, but on the other hand it has twice as large a range for the positive integers. The types TINYINT, SMALLINT, MEDIUMINT, INT and BIGINT all have signed and unsigned versions.
For INT the ranges are defined as follows:
Type Storage Min Max INT 4 -2147483648 2147483647 INT UNSIGNED 4 0 4294967295
The signed and unsigned types take the same storage space (4 bytes for INT).
See the documentation for more details.
INT goes from -2147483648
to +2147483647
UNSIGNED INT goes from 0
to 4294967295
the 11
between the braces has no effect on the number, just how it's displayed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With