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

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

## Root Cause

Floating-point arithmetic produces small representation errors. Direct equality on floats is unreliable; pytest provides pytest.approx for this purpose.

## Version Compatibility

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

## Workarounds

1. **** (98% success)
   ```
   Use pytest.approx:
  from pytest import approx
  assert 0.1 + 0.2 == approx(0.3)
  assert result == approx(expected, rel=1e-6, abs=1e-9)
   ```
2. **** (95% success)
   ```
   For numpy arrays:
  import numpy as np
  np.testing.assert_allclose(a, b, rtol=1e-6)
   ```

## Dead Ends

- **** — Works for this case but fails for very large/small magnitudes and hides genuine precision bugs. (55% fail)
- **** — Default rel_tol=1e-9 may be too strict for accumulated errors or too loose for scientific tests. (50% fail)
