Repository navigation
feat: Float64Range and Float64Set over finite doubles - #198
Merged
Merged
Conversation
Float64Range maps to the custom float8range (float8multirange), Float64Set and Float64Set<T> to double precision[]. NaN and the infinities are refused on every construction path and every scalar operand (IRange<T>.NormalizeElement, IValueSet<T>.NormalizeElement, the EF definitions' normalizeValue), because .NET sorts NaN first and PostgreSQL last. The text is exactly float8out's (Internals/FloatLiteral.cs): Ryu with acceptBounds = false and PostgreSQL's layout, measured equal on 649,929 doubles on PostgreSQL 16 and 18. .NET's shortest form differs in digits for about one double in three hundred and, on .NET 10, does not read back for 2^-25 and 2^-958, so the JSON writer, SQL literals and the wrapper arity (G17) never use it. FloatDomainParityTests is a new oracle with two seeds, both caught. Closes #196 Part of #153 Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 18, 2026
The closed-union copy constructor (#213), CompareTo in PostgreSQL's range order (#183), Shift/Expand (#185) and Split(step) (#197). Values(step) stays with the discrete types. Float arithmetic overflows to an infinity rather than throwing, so a moved bound or split boundary past the finite values throws OverflowException as for the other types, and a NaN or infinite step throws ArgumentException. Each split boundary is Start + n * step, rounded once. The arithmetic and split oracles gain a double grid step and an edge step of whole ulps at MaxValue, where half a grid unit is absorbed by rounding. Claims are renumbered onto the free ids after main's (E54-E57, M17, S22), with R40 and R41 for the new sentences. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…family divergences under the minority sweep
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 #196
Part of #153 (the
doublehalf;Float32Range/Float32Setfollow in a stacked PR that closes #153)Problem
There was no range or set over
double.docs/why.mdexcluded it for an imprecise reason (IEEE operators vsCompareTo); the real break, measured in #153, is that .NET sortsNaNfirst and PostgreSQL last.Change
Following
docs/architecture.md#adding-a-range-or-set-type: measured first, then copiedDecimalRange/DecimalSet(continuous numeric) withTimeRange's custom-type EF setup andYearMonthRange's refuse-at-construction mechanism.Float64Range(five variants, each with its own[JsonConverter]/[TypeConverter]; the unbounded variants are not positional sowith { Start = NaN }cannot bypass the check),Float64Set,Float64Set<T>(AOTConvertersRegistered, pinnedG17,ValueSetFloatElementJsonConverter), closed JSON converters,RangeAgg/RangeIntersectAgg, variantParse/TryParse.Internals/FloatLiteral.RequireFinitein every factory and constructor; a new internalIRange<T>.NormalizeElementhook applied inContains(T),Clamp(T)andRangeSet.Contains(T)(the empty and infinite shapes compare nothing, so the guard sits before the switch);IValueSet<T>.NormalizeElement; EFnormalizeValue(FiniteFloat), so aNaNparameter throws at query time and a storedNaN/Infinitythrows on load.FloatLiteral.Formatreproducesfloat8outbyte for byte (Ryu withacceptBounds = false, PostgreSQL's fixed/exponent layout). The parser isfloat8in's grammar for finite numbers, refusingNaN/inf,strtodhexadecimal, and out-of-range text thatdouble.Parsesilently turns into infinity or zero.doubleset is written and read through that text when System.Text.Json's built-in converter would have handled it — STJ's own writer prints 2^-25 as a different double.RangeTypeRegistryrow (float8range,float8multirange,double precision, nosubtype_diff),SetTypeRegistryclosed row andBridged<double>arity,SetProviderTextarm fordouble, andNeedsExplicitCastskips a definition whose own element mapping already writes a typed literal (no::double precision::double precision).docs/efcore.md"Custom range types" table (timerange,float8range;float4rangelands with PR 2) and afloat8rangesection;docs/why.mdrewritten to the measured reason with the table, one sentence on Intervals.NET, and the stricter-than-the-database entry; README "whydoubleis absent" text replaced; ranges/value-sets/package README tables. 10 new claims (W01–W04,E45–E48,M12,S20), all held. CHANGELOG under 10.0.0.Measurements (PostgreSQL 16.15 and 18.1, scratch containers; 17 in CI)
double.ToString(),"R"andUtf8JsonWriterwrite 2^-25 and 2^-958 as text that reads back one ulp lower — exactly those two (neighbourhood of every power of two exhaustively, 0 of 20M random doubles otherwise). PostgreSQL prints them correctly. Probably worth an upstream dotnet/runtime report; not filed.float8outfor 128 of 40,016 sampled doubles (values still equal), and the layout for most exponent forms.FloatLiteral.Formatmatches on 649,929 doubles on 16 and 18, 0 mismatches.subtype_diff = float8mifails GiST insert/build over extreme values with22003on 16 and 18; without it the index builds and answers.Tests
Float64DomainTests(unit, 57),Float64TranslationTests(no DB, 7),FloatDomainParityTests(integration, 5: 20,000-double text sweep vsfloat8out; range/array/multirange literals throughrange_in/array_inand EF's read leg, with the non-finite rows required to throw; NaN parameters; exact inlined constants; GiST with and withoutfloat8mi), plus Float64 rows in the shape matrix, algebra, literal-whitespace, inline-constant and catalogue tests, and every discovered sweep (fuzz, captured collections, host culture, JSON options, wrapper grammar/parity).FloatDomainParityTests, two seeds, bothCAUGHTbydotnet run tools/oracles.cs seeds float64:float64-admits-nan.patch(the[5,NaN)row loads asempty) andfloat64-literal-is-dotnet-shortest.patch(16,017 of 20,000 texts differ; the inlined 2^-25 constant matches nothing).Contains/RangeSet.Contains, the JSON float write path, the EF finite guard, theSetProviderTextdouble arm, andFloat64Set<T>'s AOT registration (the Native AOT consumer fails withNotSupportedException).StringSetwaivers went stale becauseFloat64Setnow sharesNormalizeElement).SMOKE_AOT_LINKER_ARGS).Members added in parallel sessions (scheduling, parity) will need Float64 coverage when both land.
🤖 Generated with Claude Code
Update: rebased onto the 10.0.0 members (merged origin/main)
Float64Range: the closed-union copy constructor (fix: refuse external subtypes of the range unions in the copy constructor #213, verbatim),CompareToin PostgreSQL's range order (feat: IComparable in PostgreSQL's range and multirange order #183),Shift/Expand(feat: Shift and Expand on every range type #185),Split(step)(feat: Split a range by a step or a calendar period, and Values(step) #197).Values(step)stays with the discrete types. A non-finite step throwsArgumentException; a bound pastdouble.MaxValuethrowsOverflowException(IEEE addition would give an infinity); each split boundary isStart + n × step, rounded once.RangeArithmeticOracleTestsandRangeSplitOracleTestsgain adoublegrid step and an edge step of whole ulps atMaxValue, where half a grid unit is absorbed by rounding.RangeOrderParityTests(discovered) checksCompareToagainstORDER BYonfloat8range. Reverting the copy constructor failsClosedUnionContractTests.Shift/Expand) and R41 (Splitrounding).Float64Setjoining sub-families surfaced four group divergences (Float64Set + StringSetNormalizeElement, the primitive/arityFormatValueand NodaTime element-converter groups), each waived.