# Floating-Point Number

> A number with a decimal part, like 3.5. It can be off by a hair.

**Field:** Software Development  
**Category:** Programming Concepts  
**Also known as:** Float, Decimal Number, Double

## Think of it like

Think of it like a ruler with very fine marks. It is close for nearly any length, but not always spot on.

## Definition

A floating-point number is a number with a decimal part, like 3.5. Computers store these in a fixed number of bits, so most of them are kept as a very close guess. That is why 0.1 + 0.2 can come out as 0.30000000000000004. The tiny error is fine for a game or a map. For money, programs use whole cents or a special decimal type instead.

## Example

A fitness app stores a 5.2 km run as a float. For the price of the plan it uses 999 cents, not 9.99.

## Example code

```python
>>> 0.1 + 0.2
0.30000000000000004
```

The answer is a hair off, because the computer stores a close guess.

## Why it matters

Distances, weights and scores often have decimals. Knowing the tiny error keeps you from using floats for money.

## Common mistake

Storing prices as floats. Small errors add up, and a total can end one cent off.

## Three principles

- **Has a decimal part.** Holds values like 3.5 and 0.25.
- **Close, not exact.** Most values are a very near guess.
- **Not for money.** Use whole cents or a decimal type.

## Related terms

- [Data Type](https://learn.benibix.com/term/development/data-type)
- [Integer](https://learn.benibix.com/term/development/integer)
- [Arithmetic Operator](https://learn.benibix.com/term/development/arithmetic-operator)
- [Variable](https://learn.benibix.com/term/development/variable)

## Told apart from

- [Integer vs Floating-Point Number](https://learn.benibix.com/compare/integer-vs-floating-point-number): People think 3 and 3.0 are the same number to a computer, and they are not. An integer is a whole number, and its sums are exact. A floating-point number has a decimal part, and it keeps a very close value rather than an exact one. That is why 0.1 + 0.2 can give 0.30000000000000004. For money, count in whole cents with integers.

## Taught in

- [Data Types in Python](https://learn.benibix.com/learn/development-concepts/data-types-in-python): Programming Basics, 6/18

---

Source: https://learn.benibix.com/term/development/floating-point-number
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
