All numbers in C# are value types.

The following numbers are in the system namespace,

Type Range Size
sbyte -128 to 127 Signed 8-bit integer
byte 0 to 255 Unsigned 8-bit integer
char U+0000 to U+ffff Unicode 16-bit character
short -32,768 to 32,767 Signed 16-bit integer
ushort 0 to 65,535 Unsigned 16-bit integer
int -2,147,483,648 to 2,147,483,647 Signed 32-bit integer
uint 0 to 4,294,967,295 Unsigned 32-bit integer
long -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 Signed 64-bit integer
ulong 0 to 18,446,744,073,709,551,615 Unsigned 64-bit integer

Additionally, using the system.numerics namespace you can use BigInteger.

Signed & Unsigned

For short, int and long there is both a signed and an unsigned version.

Unsigned

Number types starting with ‘u’ means that they are unsigned, but they use the same amount of memory and can store the same number length only the minimum value is set to 0 instead of a negative.

Unsigned numbers are not CLS-compliant, for more information see https://msdn.microsoft.com/en-us/library/bhc3fa7f(v=vs.90).aspx.

This means that than cannot have negative numbers, but they have a max value double that of their signed versions.

int range: 2,147,483,647 to 2,147,483,647

uint range: 0 to 4,294,967,295

The benefit of this is that you can use an int to store a larger value so long as you’re not using negatives and so you may not need to use a long instead.

Signed

References

Advertisements