Interpretation of 6.18f (floating point constant suffix) in C language

In C language, for example `6.18f`, this is a floating point constant.

`6.18` is a floating point number, and the suffix `f` indicates that the floating point number is a single precision floating point number.

In C language, the default floating-point constant type is double-precision floating-point number. If you want to use single-precision floating-point number, you can add `f` or `F` suffix after the constant .

For example, `6.18f` represents a single-precision floating point number, while `6.18` represents a double-precision floating point number. The two occupy different spaces in memory. Single-precision floating-point numbers usually occupy 4 bytes, while double-precision floating-point numbers usually occupy 8 bytes.

Using single-precision floating point numbers saves memory space, but you may lose precision because single-precision floating point numbers have fewer significant digits. When choosing to use single precision or double precision, you need to decide based on specific needs and accuracy requirements.

Guess you like

Origin blog.csdn.net/m0_73800602/article/details/133420668