Repository navigation
feat: Float32Range and Float32Set over finite floats - #199
Merged
Merged
Conversation
Float32Range maps to the custom float4range (float4multirange), Float32Set and Float32Set<T> to real[], with the same finite guard as the double families. The text is exactly float4out's, measured equal on 649,250 floats on PostgreSQL 16 and 18; float4in and float.Parse agree on 199,914 texts, half of them float midpoints and their double neighbours. Nothing formats or parses a float through double: a float printed as a double reads back as the same real, so only the text sweep sees it. The wrapper arity pins G9. No subtype_diff applies (float4mi returns real). No Half family: PostgreSQL has no two-byte float. Two more FloatDomainParityTests seeds, both caught. Closes #153 Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 18, 2026
…the 10.0.0 range members Float32Range gets the closed-union copy constructor, CompareTo, Shift/Expand and Split(step) on the same rules as Float64Range: a non-finite step throws ArgumentException, a bound past float.MaxValue throws OverflowException, and each split boundary is Start + n * step rounded once. The arithmetic and split oracles gain float grid and edge steps (whole ulps at MaxValue). Under the minority clone sweep (#200) the divergences the two float families share are reported once, and each is waived once as "Float32... + Float64..." in place of the Float64-only waivers. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #153
Stacked on #198 (
Float64Range/Float64Set, closes #196). Merge #198 first; this PR's diff is only thefloathalf.Problem
#153 asks for both widths. After #198 there is still no range or set over
float(real,float4range).Change
The same family over
float, copied from thedoubletypes and changed only where the measurement says:Float32Range,Float32Set,Float32Set<T>(pinnedG9, AOTConvertersRegistered), closed JSON converters, aggregates, variant parsing.FloatLiteral.ParseSinglereads straight tofloat(asstrtofdoes), andFloatLiteral.Format(float)isfloat4out's text — never viadouble.float4range/float4multirangeoverreal(nosubtype_diffis possible:float4mireturnsreal, and a diff must returnfloat8),real[]for the sets, aBridged<float>arity and theSetProviderTextfloatarm.float4rangerow in the efcore.md custom types table and its setup;docs/why.mdgains thefloatsentence and "Why there is noHalfrange" (PostgreSQL has no two-byte float, as there isInt16Setbut noInt16Range); value-sets listsHalfas left out; tables everywhere. ClaimsW05,E49,E50, andE45reworded for three custom types. CHANGELOG under 10.0.0.Measurements (PostgreSQL 16.15 and 18.1)
float4out(extra_float_digits 1): exponent form from1e+06(where .NET's default switches at1E+07), lowercase, two-digit exponent; digits differ from .NET's shortest for 233 of 39,940 sampled floats (RyuacceptBounds = falseagain, e.g.-90185504→ .NET-90185500, PG-9.0185504e+07). The shared formatter matches on 649,250 floats, 0 mismatches.doublediffers on 14,095 of 16,243 sampled floats (0.1f→0.10000000149011612) while every such text still reads back as the samereal— invisible to value comparisons, so it needs the text sweep.float4invsfloat.Parse: 0 mismatches over 199,914 texts, half of them exact float midpoints and their double neighbours (no double rounding on either side).realrefuses1e39,3.4028236e38and1e-46as out of range; the parser does too (float.Parsewould return infinity or zero).Tests
Float32DomainTests(56, everyfloat4outtext above),Float32TranslationTests(7:'0.1'::real,'1e+06'::real,ARRAY['0.1','1e+06']::real[], migrationreal,,,,), andFloatDomainParityTestsextended: a 20,000-float text sweep againstfloat4out,float4range/real[]/float4multirangeliterals through the server and EF's read leg, NaN operands onrealcolumns. Plus shape matrix, algebra, catalogue (rngsubdiff-), literal-whitespace, inline-constant rows and every discovered sweep (fuzz now draws floats by ULP steps and decades).CAUGHTbydotnet run tools/oracles.cs seeds float32:float32-literal-goes-through-double.patch(failsText_IsWhatFloat4OutPrints) andfloat32-admits-nan.patch(the stored[5,NaN)loads asempty).Float32Set<T>it never constructs and prints{0.1,1e+06}.🤖 Generated with Claude Code
Update: rebased onto #198 and the 10.0.0 members
Float32Rangegets the same copy constructor,CompareTo,Shift/ExpandandSplit(step), onfloat, with float grid and edge steps (2^103/2^104 atfloat.MaxValue) in the two oracles; the copy constructor is proven againstClosedUnionContractTests.Float32… + Float64…in place of feat: Float64Range and Float64Set over finite doubles #198's Float64-only waivers. The float pair's agreeingSplitbodies makeDecimalRange/Int32Range/Int64Range'sSplitlook like lone drifts; those three are waived with the reason.Float32Range.