Skip to content

Fix OpenApiFloat comparison threshold - #102

Open
Jerry-Johnson-3 wants to merge 1 commit into
criteo:mainfrom
Jerry-Johnson-3:fix/openapi-float-differfrom-threshold
Open

Jerry-Johnson-3 wants to merge 1 commit into
criteo:mainfrom
Jerry-Johnson-3:fix/openapi-float-differfrom-threshold

Conversation

@Jerry-Johnson-3

@Jerry-Johnson-3 Jerry-Johnson-3 commented Aug 24, 2026

Copy link
Copy Markdown

Summary

  • Use float.Epsilon instead of float.MinValue in DifferFrom so equal float defaults are not reported as different.
  • Add regression tests for equal and different OpenApiFloat values.

float.MinValue is a large negative number, so Math.Abs(a - b) > float.MinValue is true for every pair of floats, including identical ones.

Spec

OpenAPI number/float is IEEE 754 binary32. Equal defaults must compare equal. Single.MinValue is the most negative finite value (~-3.4e38), not a comparison epsilon.

Testing

  • Red: DifferFrom_ShouldReturn_false_When_SameOpenApiFloat failed (Expected: False, But was: True).
  • Green: both new float tests passed after the threshold change.

Use float.Epsilon instead of float.MinValue so equal float defaults are not reported as different.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

1 participant