mirror of
https://github.com/apache/nuttx.git
synced 2026-05-20 20:44:39 +08:00
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:
committed by
Alan C. Assis
parent
9503d57634
commit
23a9ff1196
@@ -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)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user