From 871cd306c58c356c710115193bb4b906d099b5a0 Mon Sep 17 00:00:00 2001 From: Yingwei Zheng Date: Wed, 31 Jul 2024 20:34:15 +0800 Subject: [PATCH] libm/copysign: respect signed zero/NaN in copysign --- libs/libm/libm/lib_copysign.c | 2 +- libs/libm/libm/lib_copysignl.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/libm/libm/lib_copysign.c b/libs/libm/libm/lib_copysign.c index f0b6c8ad3b..171b476aaa 100644 --- a/libs/libm/libm/lib_copysign.c +++ b/libs/libm/libm/lib_copysign.c @@ -34,7 +34,7 @@ #ifdef CONFIG_HAVE_DOUBLE double copysign(double x, double y) { - if (y < 0) + if (signbit(y)) { return -fabs(x); } diff --git a/libs/libm/libm/lib_copysignl.c b/libs/libm/libm/lib_copysignl.c index 58d3a32067..824403904d 100644 --- a/libs/libm/libm/lib_copysignl.c +++ b/libs/libm/libm/lib_copysignl.c @@ -34,7 +34,7 @@ #ifdef CONFIG_HAVE_LONG_DOUBLE long double copysignl(long double x, long double y) { - if (y < 0) + if (signbit(y)) { return -fabsl(x); }