mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 16:50:55 +08:00
libc/math/lib_asin.c: The function did not convert for some input values. Asin did not convert for values which do not belong to the domain of the function. But aside of that the function also did not convert for sine allowed values. I achieved a conversion of the function by reducing the DBL_EPSION and by checking if the input value is in the domain of the function. This is a fix for the problem but the function should always terminate after a given number of iterations. From Stefan Kolb.
This commit is contained in:
committed by
Gregory Nutt
parent
bb385c242f
commit
5ac6de118e
+18
-2
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* This file is a part of NuttX:
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2012, 2015 Gregory Nutt. All rights reserved.
|
||||
* Ported by: Darcy Gong
|
||||
*
|
||||
* It derives from the Rhombs OS math library by Nick Johnson which has
|
||||
@@ -35,6 +35,13 @@
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
|
||||
/************************************************************************
|
||||
* Pre-processor Definitions
|
||||
************************************************************************/
|
||||
|
||||
#undef DBL_EPSILON
|
||||
#define DBL_EPSILON 1e-12
|
||||
|
||||
/************************************************************************
|
||||
* Public Functions
|
||||
************************************************************************/
|
||||
@@ -42,7 +49,16 @@
|
||||
#ifdef CONFIG_HAVE_DOUBLE
|
||||
double asin(double x)
|
||||
{
|
||||
long double y, y_sin, y_cos;
|
||||
long double y;
|
||||
long double y_sin;
|
||||
long double y_cos;
|
||||
|
||||
/* Verify that the input value is in the domain of the function */
|
||||
|
||||
if (x < -1.0 || x > 1.0)
|
||||
{
|
||||
return NAN;
|
||||
}
|
||||
|
||||
y = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user