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 <carlossanchez@geotab.com>
This commit is contained in:
Carlos Sanchez
2026-01-14 12:25:35 +01:00
committed by Alan C. Assis
parent 9503d57634
commit 23a9ff1196
+4 -1
View File
@@ -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)));
}