{
  "id": "python/assertionerror-assert-approx-equal",
  "signature": "AssertionError: assert 0.1 + 0.2 == 0.3",
  "signature_zh": "断言错误：断言 0.1 + 0.2 == 0.3",
  "regex": "AssertionError:\\ assert\\ 0\\.1\\ \\+\\ 0\\.2\\ ==\\ 0\\.3",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Floating-point arithmetic precision issues cause the sum to be slightly off from expected value.",
  "root_cause_type": "generic",
  "root_cause_zh": "浮点运算精度问题导致总和与预期值略有偏差。",
  "versions": [
    {
      "version": "3.8",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.9",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.10",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Using round() on both sides",
      "why_fails": "round() may still produce different results due to floating-point representation.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "Multiplying by a factor to avoid decimals",
      "why_fails": "Does not eliminate the underlying precision issue; may introduce new errors.",
      "fail_rate": 0.4,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use pytest.approx for approximate comparison",
      "success_rate": 0.95,
      "how": "assert 0.1 + 0.2 == pytest.approx(0.3)",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use math.isclose with tolerance",
      "success_rate": 0.9,
      "how": "import math; assert math.isclose(0.1 + 0.2, 0.3, rel_tol=1e-9)",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2025-06-15",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}