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.