When we recently checked a server in our company, we found that many Systemtonumber crash Exception were recorded in the Windows log because of the fact that the company's colleague coding had made a most basic principle error, in view of this, I think it's necessary to comb it again. NET three basic numeric types (int, float, double).
int : in. NET ,int is a signed 32-bit integer value whose . NET Framework type is System.Int32 , regardless of whether the processor is a four-bit or a.
Float: Single-precision floating-point number, 32-bit length, 1-bit real number sign bit (original code), 1-bit exponential sign bit, 7-bit exponential bit (this eight bit is a shift code representation), and 23-bit data bits (complement), in. NET is also known as single.
double:64 bit-length double-precision floating-point number, 1-bit sign bit, 11-bit exponential bit, 52-bit data bit.
The conversion relationship of the three:
1. int can be implicitly converted to float and double;
2.float can be cast to an int only, but may be implicitly converted to double;
3.double can only be cast to float and int.
Ps:
Note the distinction: (1) Convert.ToInt32 ("56.89") and (2) convert.toint (56.89)
(1) This writing will cause the formatexception to be thrown, so use (2) this notation.
int, float, double in. NET of mutual transformation