Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240612151859.GT10433@brightrain.aerifal.cx>
Date: Wed, 12 Jun 2024 11:18:59 -0400
From: Rich Felker <dalias@...c.org>
To: Meng Zhuo <mzh@....io>
Cc: musl@...ts.openwall.com
Subject: Re: [PATCH v2] math: add riscv64 round/roundf

On Wed, Jun 12, 2024 at 11:14:13PM +0800, Meng Zhuo wrote:
> ---
> v1 -> v2:
>  * drop ±inf check and use fabs as Rich suggested

That is not the significant change. The significant change is fixing
completely wrong behavior on large finite inputs.

> ---
>  src/math/riscv64/round.c  | 21 +++++++++++++++++++++
>  src/math/riscv64/roundf.c | 21 +++++++++++++++++++++
>  2 files changed, 42 insertions(+)
>  create mode 100644 src/math/riscv64/round.c
>  create mode 100644 src/math/riscv64/roundf.c
> 
> diff --git a/src/math/riscv64/round.c b/src/math/riscv64/round.c
> new file mode 100644
> index 00000000..81991b5f
> --- /dev/null
> +++ b/src/math/riscv64/round.c
> @@ -0,0 +1,21 @@
> +#include <math.h>
> +
> +#if __riscv_flen >= 64
> +
> +double round(double x)
> +{
> +	if (isnan(x)) return x;
> +	if (fabs(x) >= 0x1p54) return x;

Did you keep the isnan test separate to avoid raising an exception, or
for other reasons?

Rich

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.