Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7358912-356d-a817-9f7e-f94716243c6@esi.com.au>
Date: Fri, 21 Jun 2024 18:16:12 +1000 (AEST)
From: Damian McGuckin <damianm@....com.au>
To: MUSL <musl@...ts.openwall.com>
Subject: Re: roundf() (and round(), and ...)

On Fri, 21 Jun 2024, Damian McGuckin wrote:

> There is an optimization in roundf() (and an equivalent in round())
> which handles the case of numbers 0 < |x| < 0.5
>
>     if (e < 0x7f-1) {
>         return 0*u.f;
>     }
>
> If one has lots of numbers close to zero (as you would if you were testing 
> even possible 32-bit floating point number or for any other reason), this
> can mean a total run time is 5% faster overall (at the expense of the 
> performance of cases for |x| >= 0.5.
>
> Is such an optimization worth it? And yes, we re not talking about lots of
> compute cycles here!

This issue also arises in an implementation roundeven() which will be 
needed for C2Y compliance.

- 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.