Dotnet Core 简明教程
.NET Core - Numerics
-
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.
Integral 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.
你还可以使用 System.BitConverter 类通过整数值中的单独位进行操作。
You can also work with the individual bits in an integer value by using the System.BitConverter class.
Floating-point types
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.
SIMD
-
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.