.NET Core - Numerics
.NET Core supports the standard numeric integral and floating-point primitives. It also supports the following types −
System.Numerics.BigInteger which is an integral type with no upper or lower bound.
System.Numerics.Complex is a type that represents complex numbers.
A set of Single Instruction Multiple Data (SIMD)-enabled vector types in the System.Numerics namespace.
.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|
Each integral type supports a standard set of arithmetic, comparison, equality, explicit conversion, and implicit conversion operators.
You can also work with the individual bits in an integer value by using the System.BitConverter class.
.NET Core includes three primitive floating point types, which are shown in the following table.
|Type||Size (bytes)||Minimum Value||Maximum Value|
|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.
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.
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.
The Numerics namespace includes a set of SIMD-enabled vector types for .NET Core.
SIMD allows some operations to be parallelized at the hardware level, which results in huge performance improvements in mathematical, scientific, and graphics apps that perform computations over vectors.
The SIMD-enabled vector types in .NET Core include the following −
System.Numerics.Vector2, System.Numerics.Vector3, and System.Numerics.Vector4 types, which are 2, 3, and 4-dimensional vectors of type Single.
The Vector <T> structure that allows you to create a vector of any primitive numeric type. The primitive numeric types include all numeric types in the System namespace except for Decimal.
Two matrix types, System.Numerics.Matrix3×2, which represents a 3×2 matrix; and System.Numerics.Matrix4×4, which represents a 4×4 matrix.
The System.Numerics.Plane type, which represents a three-dimensional plane, and the System.Numerics.Quaternion type, which represents a vector that is used to encode three-dimensional physical rotations.