Skip to content

Float

In one line

A float (floating-point number) is a number with a decimal point, like 3.14 or -0.5.

In simple words

A float is a number that can have a fractional part, represented with a decimal point. Python uses IEEE 754 double-precision (64-bit) floating-point, the same as most languages.

Floats are created by writing a literal with a decimal point (3.14), using scientific notation (1e-3), or converting with float(). Division with / always returns a float, even for integer operands.

Floats have limited precision — 0.1 + 0.2 equals 0.30000000000000004, not exactly 0.3. This is a fundamental property of floating-point arithmetic, not a Python bug. For exact decimal arithmetic, use the decimal module.

Example

python
pi = 3.14159
tiny = 1e-6
result = 7 / 2

print(pi)           # 3.14159
print(tiny)         # 1e-06
print(result)       # 3.5
print(0.1 + 0.2)    # 0.30000000000000004
print(type(pi))     # <class 'float'>

Floats have decimal points, support scientific notation, and have precision limitations.

Common confusions

  • Confused with: integer

    The difference: A float has a fractional part and limited precision. An integer is a whole number with exact precision. Use int() to truncate a float to an integer, or round() to round to the nearest integer.

Related terms

Related Resources

Related Lessons

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors

← Back to glossary