Repository navigation
What's Changed
.NET 11 support with new complex number types and enhancements by @AntonovAnton in #133
Added
- .NET 11 target.
MathEvaluatorandMathEvaluator.FastExpressionCompilernow multi-target .NET 8, .NET 9, .NET 10, and .NET 11. - .NET 11 numeric types (available on
net11.0only):- IEEE 754 decimal floating-point types
Decimal32,Decimal64,Decimal128, andBFloat16work with the genericEvaluate<T>()/Compile<T>()APIs. - Generic
Complex<T>numbers (Complex<double>,Complex<float>,Complex<Half>,Complex<BFloat16>,Complex<Decimal32>,Complex<Decimal64>,Complex<Decimal128>):EvaluateComplex<T>()onMathExpressionand onstring, with overloads for no parameters, an object,IDictionary<string, Complex<T>>,IDictionary<string, object>, andMathParameters.CompileComplex<TParameters, T>()andCompileComplexAsyncFunc<TParameters, T>().
- Variables, dictionary items, and context bindings of all these types are recognized by
MathParametersandMathContext. DotNetMathContextbinds the members of these types in C# syntax, e.g.Decimal64.Pi,Decimal128.MaxValue,BFloat16.Sqrt(x),Decimal64.Quantize(x, y),default(Decimal32), and the matchingComplex<T>members.
- IEEE 754 decimal floating-point types
- Generic math contexts:
ScientificMathContext<T>calculates scientific functions and constants in the precision of any IEEE 754 floating-point type (double,float,Half, and on .NET 11BFloat16,Decimal32,Decimal64,Decimal128).ProgrammingMathContext<T>calculates constants, floor division//, modulo%, andiifin the precision of anyIFloatingPoint<T>type, includingdecimal.ComplexScientificMathContext<T>is the scientific context for genericComplex<T>numbers (.NET 11+).
- FastExpressionCompiler async compilation:
CompileAsyncFuncFast,CompileDecimalAsyncFuncFast,CompileBooleanAsyncFuncFast, andCompileComplexAsyncFuncFaststring extensions compile expressions with async functions into aFunc<T, CancellationToken, ValueTask<TResult>>delegate. - FastExpressionCompiler generic complex compilation (.NET 11+):
CompileComplexFast<TParameters, T>()andCompileComplexAsyncFuncFast<TParameters, T>()string extensions compile expressions that return a genericComplex<T>.
Changed
-
Breaking:
ScientificMathContextandProgrammingMathContextnow inherit fromScientificMathContext<double>andProgrammingMathContext<double>. Their behavior is unchanged, but code that relies on the exact base type (for example, reflection orGetType().BaseTypechecks) is affected. -
Breaking:
DotNetStandardMathContextnow binds C# literal suffixes,default(...)values, andMinValue/MaxValueconstants with their actual types. Before, it converted them todouble. For example:1fis now afloat,1Lalong, and1uauint.int.MaxValueis now anint, anddecimal.MaxValueadecimal.
Expressions that mix these constants can produce different result types or precision than in 3.x.
-
DecimalProgrammingMathContextnow inherits fromProgrammingMathContext<decimal>. -
MathEvaluator.FastExpressionCompilernow depends onMathEvaluator4.0.0. -
EvaluatingStepevents are no longer raised for NaN constant values, and they now also apply to generic complex values.
Full Changelog: v3.8.0...v4.0.0