22 Commits

Author SHA1 Message Date
Trevor Gross
e106d63516 Add a way to print inputs on failure
When there is a panic in an extensive test, tracing down where it came
from can be difficult since no information is provides (messeges are
e.g. "attempted to subtract with overflow"). Resolve this by calling the
functions within `panic::catch_unwind`, printing the input, and
continuing.
2025-02-11 22:33:08 -06:00
Trevor Gross
53a055049c Add roundeven{,f,f16,f128}
C23 specifies a new set of `roundeven` functions that round to the
nearest integral, with ties to even. It does not raise any floating
point exceptions.

This behavior is similar to two other functions:

1. `rint`, which rounds to the nearest integer respecting rounding mode
   and possibly raising exceptions.
2. `nearbyint`, which is identical to `rint` except it may not raise
   exceptions.

Technically `rint`, `nearbyint`, and `roundeven` all behave the same in
Rust because we assume default floating point environment. The backends
are allowed to lower to `roundeven`, however, so we should provide it in
case the fallback is needed.

Add the `roundeven` family here and convert `rint` to a function that
takes a rounding mode. This currently has no effect.
2025-02-11 00:55:22 -06:00
Trevor Gross
2a3ef8b9a2 Fix parsing of negative hex float literals in util 2025-02-11 00:55:22 -06:00
Trevor Gross
669731335e Add fminimum, fmaximum, fminimum_num, and fmaximum_num
These functions represent new operations from IEEE 754-2019. Introduce
them for all float sizes.
2025-02-10 16:17:33 -06:00
Trevor Gross
9223d60dfa Add fmaf128
Resolve all remaining `f64`-specific items in the generic version of
`fma`, then expose `fmaf128`.
2025-02-06 18:41:45 -06:00
Trevor Gross
cc2874c9a9 Add scalbnf16, scalbnf128, ldexpf16, and ldexpf128
Use the generic `scalbn` to provide `f16` and `f128` versions, which
also work for `ldexp`.

This involves a new algorithm for `f16` because the default does not
converge fast enough with a limited number of rounds.
2025-02-05 13:37:54 +00:00
Trevor Gross
e283c25602 Util: also print the hex float format for outputs 2025-01-29 00:17:19 +00:00
Trevor Gross
62f0fd40d1 Use az exported from Rug
Since Rug 1.27.0, `az` is reexported. This means we no longer need to
track it as a separate dependency.
2025-01-25 00:55:03 +00:00
Trevor Gross
7c6c0c1b79 Upgrade all dependencies to the latest version
In particular, this includes updates to Rug that we can make use of [1],
[2], [3], [4].

[1]: https://gitlab.com/tspiteri/rug/-/issues/78
[2]: https://gitlab.com/tspiteri/rug/-/issues/80
[3]: https://gitlab.com/tspiteri/rug/-/issues/76
[4]: https://gitlab.com/tspiteri/rug/-/issues/73
2025-01-25 00:50:02 +00:00
Trevor Gross
71200bc3ce Add fmodf128
This function is significantly slower than all others so includes an
override in `EXTREMELY_SLOW_TESTS`. Without it, PR CI takes ~1hour and
the extensive tests in CI take ~1day.
2025-01-24 08:23:15 +00:00
Trevor Gross
67218cbaa5 Add fmodf16 using the generic implementation 2025-01-24 06:03:59 +00:00
Trevor Gross
6d5105c006 Add fminf16, fmaxf16, fminf128, and fmaxf128 2025-01-24 03:01:36 +00:00
Trevor Gross
d20a5e82a5 Add roundf16 and roundf128 2025-01-24 01:59:10 +00:00
Trevor Gross
42e22132b4 Fix the parsing of three-item tuples in util 2025-01-22 18:28:57 -05:00
Trevor Gross
c788ced502 Add the ability to parse hex, binary, and float hex with util 2025-01-22 17:03:34 -05:00
Trevor Gross
b22398d658 Add rintf16 and rintf128
Use the generic algorithms to provide implementations for these
routines.
2025-01-22 11:04:39 +00:00
Trevor Gross
6a8bb0fa80 Add floorf16 and floorf128
Use the generic algorithms to provide implementations for these
routines.
2025-01-22 08:50:06 +00:00
Trevor Gross
9064c42abe Add ceilf16 and ceilf128
Use the generic algorithms to provide implementations for these
routines.
2025-01-22 07:22:32 +00:00
Trevor Gross
186eac9227 Add sqrtf16 and sqrtf128
Use the generic algorithms to provide implementations for these
routines.
2025-01-22 05:31:13 +00:00
Trevor Gross
13b5bf3959 Add fdimf16 and fdimf128
Use the generic algorithms to provide implementations for these
routines.
2025-01-13 14:04:54 +00:00
Trevor Gross
b558b365d3 Add truncf16 and truncf128
Use the generic algorithms to provide implementations for these
routines.
2025-01-13 10:12:09 +00:00
Trevor Gross
dfa694a8e4 Add a utility crate for quick evaluation
Introduce a simple binary that can run arbitrary input against any of
the available implementations (musl, MPFR, our libm). This provides an
easy way to check results, or run specific cases against a debugger.

Examples:

    $ cargo run -p util -- eval libm pow 1.6 2.4
    3.089498284311124
    $ cargo run -p util -- eval mpfr pow 1.6 2.4
    3.089498284311124
    $ cargo run -p util -- eval musl tgamma 1.2344597839132
    0.9097442657960874
    $ cargo run -p util -- eval mpfr tgamma 1.2344597839132
    0.9097442657960874
    $ cargo run -p util -- eval libm tgamma 1.2344597839132
    0.9097442657960871
    $ cargo run -p util -- eval musl sincos 3.1415926535
    (8.979318433952318e-11, -1.0)
2025-01-13 04:43:48 -05:00