Conversions between int, float, and double In. Net, floatdouble

Source: Internet
Author: User

Conversions between int, float, and double In. Net, floatdouble

Recently, when checking a Server in our company, we found that many system tonumber Crash exceptions are recorded in Windows logs. The problem is that our colleagues made a basic principle error during Coding, in view of this, I think it is necessary to sort it out again. net three basic numeric types (int, float, double ),.

Int: In. NET, int Is a signed 32-bit integer value. Whether the processor is 32-bit or 64-bit, its. NET Framework type is System. Int32.

Float: Single-precision floating point number, 32-bit length, 1-bit real number symbol bit (original code), 1-bit index symbol bit, 7-bit index bit (this eight-bit is a shift code representation) and 23-bit data bits (complement representation) in. net, also known as Single.

Double: 64-bit length Double-precision floating point number, 1-bit symbol bit, 11-bit index bit, 52-Bit Data bit.

The conversion relationship between the three elements:

1. int can be implicitly converted to float and double;

2. float can only be forcibly converted to int, but can be implicitly converted to double;

3. double can only be forcibly converted to float and int.

PS:

Note: (1) Convert. ToInt32 ("56.89") and (2) Convert. ToInt (56.89)

(1) This write method will throw a FormatException, so use (2.

 

Related Article

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.