Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 6 Dec 2017 11:37:09 +0100
From: Szabolcs Nagy <>
Subject: Re: remquo - underlying logic

* Damian McGuckin <> [2017-12-06 12:17:40 +1100]:
> While my exploration with floating point numbers was less than stellar,
> I did notice that when
> 	ex - ey < p (where p is the digits in the significant)
> you can use the
> 	fma
> routine to compute some appropriately rounded/truncated version of the
> quotient for both remquo and fmod. And this appears to not loose any
> precision for the obvious reasons.
> > From my limited testing, the speed gain for this extremely limited range
> of exponent difference is huge over the standard routine in MUSL. I will do
> some more testing and report in detail but it seems to be orders of
> magnitude.
> Somebody might want to comment on that sort of approach.

it's not clear to me how you use fma (x-(int)(x/y)*y ?),
but efficient fma instruction is not available on all
targets and the software implementation can be very slow.
and i suspect such approach would break fenv correctness.

assuming you rely on exact fma result you may need two
different implementation depending on FP_FAST_FMA
(which is currently missing in musl).

(musl is compiled with -std=c99 so x*y+z is not contracted
to fma(x,y,z) automatically when the instruction is
available, you have to add -ffp-contract=fast if that's
what you want, but it might break some code in musl that
relies on exact arithmetics, most math code should work
either way though.)

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.