Get isfinite, isinf, and isnan right in jerry-math (#4497)
- `finite` is not C99 but a BSD fp classification function, so it is removed. - The standard specifies that `isnan` is a macro (just like `isfinite` and `isinf`), so the `isnan` function implementation is removed. - `isfinite` incorrectly classified NAN as finite, which is fixed. - `isinf` returned 1 for negative infinity. This is not a bug according to the standard, but is not aligned with recent glibc, which returns -1. This is changed to simplify testing. - Added test cases for `isfinite` and `isinf` to the unit test of jerry-math. - Added a new pass to unittests to ensure that jerry-math is tested. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
This commit is contained in:
@@ -27,8 +27,8 @@ extern "C"
|
||||
#define HUGE_VAL INFINITY
|
||||
|
||||
#define isnan(x) ((x) != (x))
|
||||
#define isinf(x) (((x) == INFINITY) || ((x) == -INFINITY))
|
||||
#define isfinite(x) (!(isinf(x)) && (x != NAN))
|
||||
#define isinf(x) ((x) == INFINITY ? 1 : (x) == -INFINITY ? -1 : 0)
|
||||
#define isfinite(x) (!isinf(x) && !isnan(x))
|
||||
|
||||
/* Exponential and Logarithmic constants. */
|
||||
#define M_E 2.7182818284590452353602874713526625
|
||||
|
||||
Reference in New Issue
Block a user