# AssertionError: assert 0.30000000000000004 == 0.3
E    +  where 0.30000000000000004 = 0.1 + 0.2

- **ID:** `python/pytest-assertion-approx-float`
- **Domain:** python
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Binary floating-point representation cannot represent 0.3 exactly; direct equality on floats is unreliable.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 7.x | active | — | — |
| 8.x | active | — | — |

## Workarounds

1. **** (98% success)
   ```
   import pytest

def test_sum():
    assert 0.1 + 0.2 == pytest.approx(0.3)
    assert [0.1, 0.2] == pytest.approx([0.1, 0.2])
   ```
2. **** (95% success)
   ```
   import math

def test_sum():
    assert math.isclose(0.1 + 0.2, 0.3, rel_tol=1e-9, abs_tol=1e-12)
   ```

## Dead Ends

- **** — Works for some values but fails for very large or very small magnitudes; not a general solution. (50% fail)
- **** — String representations vary across Python versions and locales; brittle. (70% fail)
