Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - What's the difference between int and float in C language?
What's the difference between int and float in C language?
First, refer to different

1, int: is a data type. Use programming languages (C, C++, C#, Java, etc. ), which is an identifier used to define an integer variable.

2.float: store single-precision floating-point numbers or double-precision floating-point numbers.

Second, the data range is different.

1 and int: int occupy 4 bytes and 32 bits, and the data range is-2147483648 ~ 2147483647 [-231~ 231].

2. The 2.float:loat type provides a range from -3.4e+38 to 3.4e+38.

Third, the characteristics are different.

1, int: In addition to the int type, there are also short, long and long long types that can represent integers.

2.float: a type that can be promoted to a larger cardinality (from float type to double type). When performing arithmetic operations on floating-point variables, promotion usually occurs. The algorithm is always executed with the same precision as the variable with the highest precision.

Baidu encyclopedia -INT

Baidu Encyclopedia-Floating