This commit is contained in:
@@ -75,8 +75,32 @@ DoubleDouble quarterTurn = DoubleDouble.PiOver2;
|
||||
The factors avoid deriving constants at runtime; the multiplication itself remains
|
||||
approximate DD arithmetic, so conversions are not guaranteed exact round trips.
|
||||
The list is mathematical and dimensionless, not a table of unit-dependent physical
|
||||
constants. Precomputed roots/logarithms do not imply general `Sqrt`/`Log` functions
|
||||
are implemented.
|
||||
constants. Precomputed logarithms do not imply a general `Log` function is implemented.
|
||||
|
||||
## Mathematical functions
|
||||
|
||||
The initial `DDMath` static class provides:
|
||||
|
||||
- `Abs(DoubleDouble)`: preserves both components, maps either signed zero to
|
||||
positive zero and either infinity to positive infinity, and returns canonical NaN.
|
||||
It shares the existing `DoubleDouble.Abs` implementation.
|
||||
- `Sqrt(DoubleDouble)`: uses power-of-two scaling and an FMA-based Newton correction
|
||||
to retain extended precision, including for subnormal inputs, without squaring
|
||||
an unscaled estimate near the exponent limits. Signed zero and positive infinity
|
||||
are preserved; negative nonzero inputs and NaN return canonical NaN.
|
||||
|
||||
```csharp
|
||||
using Just.PreciseMath;
|
||||
|
||||
DoubleDouble root = DDMath.Sqrt(new DoubleDouble(2.0));
|
||||
DoubleDouble magnitude = DDMath.Abs(-root);
|
||||
```
|
||||
|
||||
Square-root tests compare the exact component sum against a `2^-100` relative
|
||||
error bound using integer inequalities. They include samples at every binary64
|
||||
exponent, boundary neighbors, both signs of the low component, and exact binary
|
||||
squares. This is a tested approximate-accuracy contract, not exhaustive coverage
|
||||
of all component pairs or a guarantee of correctly rounded results.
|
||||
|
||||
## Conversions and formatting
|
||||
|
||||
@@ -165,8 +189,8 @@ bool success = DoubleDouble.TryParse("1.25e-2".AsSpan(), CultureInfo.InvariantCu
|
||||
|
||||
## Deferred scope
|
||||
|
||||
The planned `PreciseMath` static class and its `Abs`, `Sqrt`, `Pow`, `Exp`, and
|
||||
`Log` functions are not implemented. Generic-math interfaces beyond `ISignedNumber`,
|
||||
The `DDMath.Pow`, `DDMath.Exp`, and `DDMath.Log` functions remain unimplemented.
|
||||
Generic-math interfaces beyond `ISignedNumber`,
|
||||
additional text formats/general round-trip formatting, and non-arithmetic performance
|
||||
benchmarks remain deferred.
|
||||
Replacing allocating arithmetic boundary fallbacks is also deferred; the current
|
||||
|
||||
Reference in New Issue
Block a user