BigInteger and complex are two of the new value types in. NET 4, which are located under the System.numeric namespace and need to be added separately.
BigInteger
The BigInteger type is an immutable type, representing an arbitrarily large integer whose value theoretically has no upper and lower bounds. This type is not used with other. NET framework integral types, which have been indicated by the MinValue and MaxValue properties for a range. Because it has no upper and lower bounds, any operation that causes the BigInteger value to grow too large causes a memory overflow exception to be-outofmemoryexception.
Static void Main (string[] args) { System.numerics. BigInteger googol= system.numerics. BigInteger. Pow (10,100); Console. WriteLine (Googol); Console. ReadKey (); } |
?
Results:
?
Complex
Complex represents a complex number, and we know that complex numbers have real and imaginary parts, and when instantiating and manipulating complex numbers, the complex type uses Cartesian coordinate systems (real numbers, imaginary figures). A complex number can be represented as a point in a two-dimensional coordinate system, the real part of the complex is on the X axis, and the imaginary part is on the Y axis.
Static void Main (string[] args) { var z1 = new system.numerics. Complex (1, 2); var z2 = new system.numerics. Complex (3, 3); ? var r1 = system.numerics. Complex. Add (z1, Z2); var r2 = system.numerics. Complex. Subtract (z1, Z2); var r3 = System.numerics. Complex. Multiply (z1, Z2); var r4 = System.numerics. Complex. Divide (z1, Z2); ? Console. WriteLine ("Z1+Z2:" + R1); Console. WriteLine ("Z1-Z2:" + R2); Console. WriteLine ("Z1XZ2:" + R3); Console. WriteLine ("Z1/Z2:" + R4); ? Console. ReadKey (); } |
?
Results:
?
?
BigInteger and Complex:net 4 new data types