BigInteger and Complex:net 4 new data types

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.