Skip to content

Ultra-narrow float ranges: more bins than representable values, so centres do not map back to their bins #86

Closed

Description

@guijacquemet

This FILE item comes from the external review of #85 (ChatGPT batch 28, claim C1). It is not a blocker.

Take the range [0, smallest subnormal] with 4 bins. It holds fewer representable float64 values than bins. float_bin_centres() therefore returns the endpoints twice (0, 0, 5e-324, 5e-324), and centres 1 and 2 do not map back to bins 1 and 2 through _bin_index. No representable value can fall in those inner bins, so no measured value is wrong. But the "bins and centres agree" invariant is silently untrue there.

Fix: pick one of these and test it.

  • Document that bins no value can fall in may share a representative centre.
  • Reduce the effective bin count, recording that it was reduced, when the range holds fewer representable floats than the requested bins.

The review also notes that the claim "every previously valid histogram is bit-identical" can only be shown by running the old and new code on a generated corpus that includes extremes and subnormals. Consider adding that comparison.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions