Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <966417d6-f8e3-787c-2c51-31738a845cbd@esi.com.au>
Date: Fri, 12 Jul 2024 10:23:36 +1000 (AEST)
From: Damian McGuckin <damianm@....com.au>
To: Szabolcs Nagy <nsz@...t70.net>
cc: MUSL <musl@...ts.openwall.com>
Subject: Re: Double Rounding in ....


belatedly ...

On Sat, 11 Nov 2023, Szabolcs Nagy wrote:

> so simply split the scale factor such that the first scaling can
> only do rounding if the second scaling (<0x1p-53) completely rounds
> the entire result away.

That is a very (extremely) elegant solution to the problem.

Who came up with the algorithm used in MUSL? It seems superior to what is 
in most other libraries. It is so much cleaner than the algorithms used in 
most other libraries which use the algorithm (or a minor variant of the 
one) in the SUN library. And it is faster.  Maybe in 30+ years ago when a 
multiplication was much slower compared to branching, the older algorithm 
made more sense. It seems such a long time ago

After your comment about moving to asfloat()/asuint() and friends the 
other day, I used scalbnf() as a test case.

By trying to work only with an unsigned biased exponent, I managed to get 
the code for scalbnf from GCC11 from an original 47 LOC of assembler to 
just 39 in the rewrite. Almost small enough to have as an inline routine.
By LOC I include the labels as well.

Interestingly, CLANG17 was only 42 LOC of assembler for the original. And
only fractionally less at 41 LOC in the rewrite which was unusual.

Thanks again for your explanation - Damian

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.