Skip to content

Conversation

@atksh
Copy link
Owner

@atksh atksh commented Nov 8, 2025

Investigated reported issue of false negatives in overlap detection due to
float32 rounding. Created extensive test suite and detailed analysis report.

Changes:

  • Add FLOAT32_PRECISION_ANALYSIS.md: Comprehensive investigation report

    • Documented code-level vulnerabilities in float32 precision handling
    • Identified asymmetry between float64 and float32 input handling
    • Analyzed theoretical risks and edge cases
    • Provided recommendations for mitigation
  • Add test_float32_overlap_issue.py: Basic precision tests

    • Very small overlap detection
    • Float32 precision boundary tests
    • Query method verification
    • ULP (Unit in Last Place) separation tests
  • Add test_float32_refined.py: Advanced precision tests

    • Internal float32 representation verification
    • Mixed precision (float32 tree + float64 query) scenarios
    • Gap creation via rounding
    • Specific failing case analysis
  • Add test_float32_extreme.py: Extreme edge case tests

    • Minimal overlap at ULP boundaries
    • Negative coordinates with precision loss
    • Accumulated rounding errors
    • Subnormal float32 values
    • Double rounding effects

Findings:

  • Confirmed code vulnerability: float32 input lacks refinement mechanism
  • Float64 input uses idx2exact for precision refinement, float32 does not
  • Unable to reproduce false negatives in synthetic tests
  • Closed interval semantics (<=) properly handles touching boxes
  • Issue likely requires specific real-world data to reproduce

Note: All tests pass without detecting false negatives, suggesting the
issue may be context-dependent or require specific coordinate patterns.

Investigated reported issue of false negatives in overlap detection due to
float32 rounding. Created extensive test suite and detailed analysis report.

Changes:
- Add FLOAT32_PRECISION_ANALYSIS.md: Comprehensive investigation report
  - Documented code-level vulnerabilities in float32 precision handling
  - Identified asymmetry between float64 and float32 input handling
  - Analyzed theoretical risks and edge cases
  - Provided recommendations for mitigation

- Add test_float32_overlap_issue.py: Basic precision tests
  - Very small overlap detection
  - Float32 precision boundary tests
  - Query method verification
  - ULP (Unit in Last Place) separation tests

- Add test_float32_refined.py: Advanced precision tests
  - Internal float32 representation verification
  - Mixed precision (float32 tree + float64 query) scenarios
  - Gap creation via rounding
  - Specific failing case analysis

- Add test_float32_extreme.py: Extreme edge case tests
  - Minimal overlap at ULP boundaries
  - Negative coordinates with precision loss
  - Accumulated rounding errors
  - Subnormal float32 values
  - Double rounding effects

Findings:
- Confirmed code vulnerability: float32 input lacks refinement mechanism
- Float64 input uses idx2exact for precision refinement, float32 does not
- Unable to reproduce false negatives in synthetic tests
- Closed interval semantics (<=) properly handles touching boxes
- Issue likely requires specific real-world data to reproduce

Note: All tests pass without detecting false negatives, suggesting the
issue may be context-dependent or require specific coordinate patterns.
Extended float32 precision investigation based on the hypothesis that
rounding direction differences could cause false negatives. Discovered
false positive case instead and updated comprehensive analysis.

New Test Scripts:
- test_rounding_direction.py: Tests for rounding direction mismatches
  - Attempts to find values that round in opposite directions
  - Tests guaranteed opposite rounding at float32 precision boundaries
  - Explores midpoint rounding and nextafter gaps

- test_different_sources.py: Tests values from different sources
  - Computed vs literal values
  - Accumulated computation effects
  - Separate float32 array creation
  - Binary representation differences
  - **FOUND FALSE POSITIVE**: accumulated_f64 < direct_f64 (no overlap)
    but both round to 100.0 in float32 (false overlap detected)

- test_false_negative_found.py: Systematic false negative search
  - Accumulated overlap loss scenarios
  - Different accumulation rates
  - NextAfter gap exploration
  - String roundtrip testing

Key Findings:
1. False Positive Discovered:
   - Float64: sum(0.1 for _ in range(1000)) ≈ 99.999 < 100.0 (no overlap)
   - Float32: both values round to 100.0 (overlap detected)
   - This is the INVERSE of the reported issue

2. False Negative Still Not Reproduced:
   - Closed interval semantics (<=) handles all boundary cases correctly
   - Consistent rounding ensures internal consistency
   - All touching boxes are properly detected

3. Theoretical False Negative Scenarios Identified:
   - Different computation paths leading to same logical value
   - Compiler optimization with intermediate precision
   - FPU settings and register precision differences
   - Data pipeline inconsistencies
   - Platform-dependent floating point behavior

Updated FLOAT32_PRECISION_ANALYSIS.md:
- Added rounding direction investigation section
- Documented false positive discovery
- Expanded theoretical risk analysis
- Added compiler/FPU/platform considerations
- Updated recommendations and next steps

Conclusion:
While false negatives could not be reproduced synthetically, false positives
were found. The reported issue likely requires specific real-world data,
compiler settings, or platform configurations to manifest. Requesting
concrete failing examples from reporter for further investigation.
@atksh atksh closed this Nov 8, 2025
@atksh atksh deleted the claude/fix-float32-overlap-detection-011CUur2tdgMM93fsNGf7C3P branch November 8, 2025 05:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants