Numerics
Integral types
.NET Core supports both signed and unsigned integers of different ranges from one byte to eight bytes in length. All integers are value types.
The following table represents the integral types and their size;
| Type | Signed/ Unsigned | Size (bytes) | Minimum Value | Maximum Value |
|---|---|---|---|---|
| Byte | Unsigned | 1 | 0 | 255 |
| Int16 | Signed | 2 | 32,768 | 32,767 |
| Int32 | Signed | 4 | 2,147,483,648 | 2,147,483,647 |
| Int64 | Signed | 8 | 9,223,372,036,854,775,808 | 9,223,372,036,854,775,807 |
| SByte | Signed | 1 | -128 | 127 |
| UInt16 | Unsigned | 2 | 0 | 65,535 |
| UInt32 | Unsigned | 4 | 0 | 4,294,967,295 |
| UInt64 | Unsigned | 8 | 0 | 18,446,744,073,709,551,615 |
Each integral type supports a standard set of arithmetic, comparison, equality, explicit conversion, and implicit conversion operators.
Floating-point types
.NET Core includes three primitive floating point types, which are shown in the following table.
| Type | Size (bytes) | Minimum Value | Maximum Value |
|---|---|---|---|
| Double | 8 | 1.79769313486232e308 | 1.79769313486232e308 |
| Single | 4 | 3.402823e38 | 3.402823e38 |
| Decimal | 16 | 79,228,162,514,264,337,593,5 43,950,335 | 79,228,162,514,264,337,593,543,9 50,335 |
Each floating-point type supports a standard set of arithmetic, comparison, equality, explicit conversion, and implicit conversion operators.
You can also work with the individual bits in Double and Single values by using the BitConverter class.
The Decimal structure has its own methods, Decimal.GetBits and Decimal.Decimal(Int32()), for working with a decimal value's individual bits, as well as its own set of methods for performing some additional mathematical operations.
BigInteger
System.Numerics.BigInteger is an immutable type that represents an arbitrarily large integer whose value in theory has no upper or lower bounds.
The methods of the BigInteger type is closely parallel to those of the other integral types.
Complex
The System.Numerics.Complex type represents a complex number, i.e., a number with a real number part and an imaginary number part
It supports a standard set of arithmetic, comparison, equality, explicit conversion, and implicit conversion operators, as well as mathematical, algebraic, and trigonometric methods.