{
  "schema_version": "1.3.0",
  "slug": "when-does-negative-zero-compare-equal-to-zero-but-produce-different-serialized-output",
  "title": "When does negative zero compare equal to zero but produce different serialized output?",
  "date_of_record": "2026 November 2",
  "scope": "Applies to systems that serialize floating-point zero across a boundary that also performs equality comparisons, where -0.0 and 0.0 are treated as equivalent by the comparator but differently by the serializer. Excludes integer-only paths and systems that canonicalize zeros at construction.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/when-does-negative-zero-compare-equal-to-zero-but-produce-different-serialized-output.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/when-does-negative-zero-compare-equal-to-zero-but-produce-different-serialized-output.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/when-does-negative-zero-compare-equal-to-zero-but-produce-different-serialized-output.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 754,
    "python_slice_tokens": 106,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "**Predicate.** IEEE-754 defines -0.0 == 0.0 as true, but `copysign` reveals the sign bit is preserved. Serializers differ: some emit `-0.0`, some emit `0.0`, some emit `-0`. A comparison passes; a byte-level equality check fails. **Failure.** A computed value reaches -0.0 (underflow, negation of zero, multiplication by negative). It compares equal to 0.0 in ...",
    "what_was_observed": "**Signature.** Cache misses for keys that compare equal. Duplicate rows with values that `==` says are the same but `hash()` says are different (in languages where `hash(-0.0) != hash(0.0)`). Serialized payloads differing only in a leading minus sign. **Trace.** A pricing calculation returns `-0.0` for a zero-dollar discount. `hash(-0.0) == hash(0.0)` in Python but `str(-0.0) == '-0.0'`. A dedup key built from `str(v...",
    "condition_of_validity": "Zero handling is consistent only while at least one holds: 1. **Canonicalization.** Every zero is normalized to `+0.0` at the earliest boundary, and the sign is not propagated. 2. **Byte-equality.** No system compares serialized forms of floats as bytes; deduplication and caching are performed on the numeric value with canonicalized zero. 3. **Type substitut...",
    "decision_boundary": "- Canonicalized to +0.0: safe. - Byte-equality comparison over uncanonicalized serialized floats: unsafe. - Serialization boundary preserving -0.0 into a cache key: unsafe. - Integer zeros in JSON: safe, but converts the schema from float to int.",
    "operational_effect": "The defect is small, rare, and easy to dismiss as a curiosity until a reconciliation fails on a zero-dollar row. Remediation is canonicalization. The trap is to test with `==`, which cannot observe the problem. Every test that expects to catch this must compare serialized bytes."
  },
  "matched_failure_symptoms": [
    "DOMAIN:EPISTEMIC_PROVENANCE_AND_FEDERATION_ROUTING"
  ],
  "composition_edges": {
    "primary_domain": "epistemic_provenance_and_federation_routing",
    "upstream_precondition_residuals": [
      "https://corpusfetch.com/c/according-to-what-precedence-hierarchy-must-an-instance-resolve-contradictory-directives-across-system-developer-and-user-tiers.md",
      "https://corpusfetch.com/c/how-should-an-instance-decide-that-a-stored-conclusion-has-gone-stale-without-a-new-observation.md"
    ],
    "downstream_consequence_residuals": [
      "https://corpusfetch.com/c/by-what-checkpoint-and-compaction-boundaries-must-an-instance-externalize-working-state-to-prevent-context-window-drift-and-truncation-amnesia.md",
      "https://corpusfetch.com/c/across-what-additive-schema-and-unknown-field-preservation-boundaries-must-an-instance-evolve-wire-contracts-to-prevent-rolling-deploy-deserialization-crashes.md"
    ],
    "co_occurring_sibling_residuals": [
      "https://corpusfetch.com/c/how-can-an-instance-capture-implicit-user-preferences-without-storing-private-data.md",
      "https://corpusfetch.com/c/how-can-an-instance-compress-long-reasoning-traces-into-binding-conclusions.md"
    ]
  },
  "empirical_verification_warrant": {
    "status": "AST_AND_INVARIANT_VERIFIED",
    "syntax_valid": true,
    "code_sha256": "71acc8b169b4e086f61568ecfb96aa148142990b0a722790a0cdc8e86614aecf",
    "verified_classes": [
      "SignedZeroError",
      "ZeroGate"
    ],
    "verified_functions": [
      "dispatch_zero_handling",
      "verify"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "SignedZeroError"
    ],
    "sample_fail_closed_invariants": [
      "-0.0 compares equal to 0.0 but serializes differently: byte-equality caches and dedup keys will diverge"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "math"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
