Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Initialization: truncation from "double precision" to "floating point"
Initialization: truncation from "double precision" to "floating point"
In C language, if the data type is not specified, the decimal constant will be regarded as a double-precision type. ?

Such as: float x;;

x = 1.2;

Where x is a floating-point type, but 1.2 is a double-precision type. Because it is a constant, the compiler is called const double. Double cannot be implicitly converted to float, but can be changed to x =1.2f; Or x =1.2f; Do it.

Extended data:

The difference between double precision and floating point

The main differences between the two are as follows:

1. The number of bytes in memory is different:

Single-precision floating-point numbers occupy 4 bytes in machine memory.

Double-precision floating-point numbers occupy 8 bytes in machine memory.

2. The significant digits are different:

Single-precision floating point number with 8 significant digits

Significant bits of 16 double-precision floating-point number

3. Value range:

The range of single-precision floating-point numbers is -3.40E+38~3.40E+38.

The expression range of double-precision floating-point numbers is-1.79e+308 ~-1.79e+308.

4. The processing speed in the program is different:

Generally speaking, the CPU can process single-precision floating-point numbers faster than double-precision floating-point numbers.