This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 23a9ff1196b libm: prevent atanf() yielding NaN for high inputs values.
23a9ff1196b is described below
commit 23a9ff1196b6fc14fe85eeddb819a016d55af798
Author: Carlos Sanchez <[email protected]>
AuthorDate: Wed Jan 14 12:25:35 2026 +0100
libm: prevent atanf() yielding NaN for high inputs values.
Without this fix, values of x where x * x + 1 are rounded
down could make asin() argument to be out of range.
Signed-off-by: Carlos Sanchez <[email protected]>
---
libs/libm/libm/lib_atanf.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/libs/libm/libm/lib_atanf.c b/libs/libm/libm/lib_atanf.c
index 08547152c46..65376153f79 100644
--- a/libs/libm/libm/lib_atanf.c
+++ b/libs/libm/libm/lib_atanf.c
@@ -31,12 +31,15 @@
#include <math.h>
#include <stddef.h>
#include <stdint.h>
+#include <sys/param.h>
/****************************************************************************
* Public Functions
****************************************************************************/
+#define ABS(a) ((a) > 0 ? (a) : -(a))
+
float atanf(float x)
{
- return asinf(x / sqrtf(x * x + 1.0F));
+ return asinf(x / MAX(ABS(x), sqrtf(x * x + 1.0F)));
}