Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,18 @@ back by the matching power of two. A root that does not settle throws `Arithmeti
than returning an estimate. The logarithmic scales and the hand-written audio types still compute
through `double`.

`StorageMath` is public API, not just the generator's helper (#239): an application doing its own
vector math over quantities would otherwise reimplement the root, and worse. `Cbrt`, `RootN` and
`Hypot` ship alongside `Sqrt` on the same seeding and the same Newton loop. `Sqrt` keeps its round
trip through `double` for every primitive, integers included, because the generated code always
inlined it; `Cbrt` and `RootN` take that route only for the binary floating point primitives and
refine every integer type in integer arithmetic, so their floor is exact rather than whatever
`Math.Pow` rounded to. `Hypot` computes a fractional type from the ratio of its legs, so a pair whose
squares leave the type still has its hypotenuse, and squares an integer type directly, since the
ratio of two integers is not a ratio. The seeding, the double round trip and the Newton loop itself
stay private — `StorageMathTests.TheRootsArePublicAndTheirWorkingsAreNot` pins both halves of that,
since this is a package with a compatibility baseline and the shape is frozen once it ships.

`StorageConversionTests<T>` runs the same conversions, relationships and vector lengths over
`double` and `decimal`, exactly where the answer terminates and to a relative tolerance where it
does not. Adding a storage type is one derived class.
Expand Down
1 change: 1 addition & 0 deletions Semantics.Quantities/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ ForceMagnitude<double> weight = Mass<double>.FromKilogram(70.0) * AccelerationMa
| `IVector2` / `IVector3` / `IVector4` | Directional vectors with `X`/`Y`/`Z`/`W`, `Length()`, `LengthSquared()`, `Dot`, `Distance`, `Normalize`; `IVector3` adds `Cross`. |
| `Vector0Guards` | `EnsureNonNegative(value, name)` and `EnsurePositive(value, name)`, used by generated `From{Unit}` factories. |
| `UnitSystem` | enum classifying units (`SIBase`, `SIDerived`, `Metric`, `Imperial`, ...). |
| `StorageMath` | `Sqrt`, `Cbrt`, `RootN` and `Hypot` over any `T : struct, INumber<T>`, with no `IRootFunctions<T>` constraint, which `decimal` could not meet. Generated `Length()` and `Distance()` use them; an application computing a norm the generator does not emit can too. |

### Generated quantity types

Expand Down
Loading
Loading