Skip to content
Open
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
21 changes: 21 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,27 @@ errors.

- `std/nre2` is added to replace deprecated NRE.

- `std/dec64` adds Douglas Crockford's
[Dec64](https://www.crockford.com/dec64.html) 64-bit decimal floating-point
type: a packed `int64` with a 56-bit signed coefficient and an 8-bit signed
exponent. Provides arithmetic, comparison, hashing, parsing, and `$`,
plus a `'dec` custom literal (`1.25'dec`) and mixed `(Dec64, int)`
operator overloads so expressions like `price * 2 + 1` work without
wrapping every integer. Decimal-native rounding (`floor`, `ceil`,
`trunc`, `round`), `abs`, `sign`, and integer-exponent `pow` stay in
pure decimal throughout.
- `std/dec64math` adds elementary mathematical functions for `Dec64`:
`sqrt`, `exp`, `ln`/`log`, `log2`, `log10`, `sin`, `cos`, `tan`,
`arcsin`, `arccos`, `arctan`, `arctan2`, `sinh`, `cosh`, `tanh`,
`pow(Dec64, Dec64)`, `nthRoot`, and exact-integer `factorial`.
Transcendentals are evaluated by round-tripping through `float64` and
delegating to `std/math`, which trades ~1 ulp at the 16th decimal
digit (Dec64's last) for a pure-Nim implementation that wraps the
battle-tested `libm` rather than reimplementing polynomials. For
computations that must stay decimal end-to-end (typically money), use
the operators in `std/dec64` directly; the transcendentals here are
for scientific or measurement-style work where the last ulp is noise.

[//]: # "Changes:"

- `std/math` The `^` symbol now supports floating-point as exponent in addition to the Natural type.
Expand Down
8 changes: 8 additions & 0 deletions doc/lib.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,14 @@ Math libraries
* [complex](complex.html)
Complex numbers and relevant mathematical operations.

* [dec64](dec64.html)
Crockford's DEC64 64-bit decimal floating-point type: exact decimal
arithmetic with a 56-bit coefficient and 8-bit exponent.

* [dec64math](dec64math.html)
Elementary mathematical functions (sqrt, exp, log, trig, factorial)
for the `Dec64` type.

* [fenv](fenv.html)
Floating-point environment. Handling of floating-point rounding and
exceptions (overflow, zero-divide, etc.).
Expand Down
Loading
Loading