Can anyone tell the meaning of the bold portion?
Float: It is used to store decimal numbers (numbers with floating point value) with single precision.
Computer Science Stack Exchange is a question and answer site for students, researchers and practitioners of computer science. It only takes a minute to sign up.
Sign up to join this communityCan anyone tell the meaning of the bold portion?
Float: It is used to store decimal numbers (numbers with floating point value) with single precision.
You seem to be asking about some text on this page: https://www.geeksforgeeks.org/data-types-in-c/
The text about the float
type is intended to say that float
stores a single precision floating point value. The "single precision" refers to a specific well-known format for storing floating point values in computers; single precision values are 32 bits in size.
Floating point values are values represented internally in a fashion somewhat similar to scientific notation but using 2 instead of 10 as the number raised to a power. The 32 bits are separated in a sign, exponent, and mantissa, and the value stored by a floating point variable is:
$$ (-1)^\mathit{sign} \times 2^\mathit{exponent} \times (1.\mathit{mantissa}) $$
(Technically here, I'm talking about binary floating point, but that's what C's float
type is.)
In a single precision float, the exponent is eight bits wide and the mantissa is twenty-three bits. (the sign is always one bit in any size floating point value)
The practical upshot of this is that you can use float
variables to store real values that aren't integers; for example 1.5 or 3.14159. You should be aware that the way binary floating point numbers work is sometimes confusing and frustrating to new programmers; a basic guide to those issues can be found at https://floating-point-gui.de/.