google / google/xls

Add additional reference for FP ops

Open
#377 0 comments 0 reactions 0 assignees View on GitHub
good first issue modules testing
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.