Add additional reference for FP ops
- Dominant language
- C++
- Stars
- 1.9k
- Forks
- 283
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 135
Description
From an internal review:
> ...use infinite precision rationals, which you can find in the GMP library:
> "High-level rational arithmetic functions (mpq)."
>
> 1. Convert floats to rationals https://gmplib.org/manual/Rational-Conversions
> 2. Multiply and add as rationals. https://gmplib.org/manual/Rational-Arithmetic This is the true, unrounded answer.
> 3. Convert your float FMA result to rational, as well as the two nearby floats (use `nexttoward`) to rational. Your FMA answer should be closer (i.e. smaller difference) to the unrounded rational (from step 2) than both of the nearby floats. When there is a tie (your result and one of the nearby floats are equally close to the exact rational result), then the chosen rounding mode tells you which of the two floats is the correctly rounded FMA result.
Seems like something that'd be relatively easy to wrap in a quick testing helper lib, so...howabout I do that?
Contributor guide
Assessment
This issue has not been assessed yet.