Coverage Report

Created: 2017-04-15 07:07

/home/travis/build/MoarVM/MoarVM/src/math/num.c
Line
Count
Source
1
#include "moar.h"
2
#include <math.h>
3
4
#ifdef _WIN32
5
#include <float.h>
6
#endif
7
8
#if defined(INFINITY) && !defined(_AIX)
9
static const MVMnum64 MVM_NUM_POSINF =  INFINITY;
10
static const MVMnum64 MVM_NUM_NEGINF = -INFINITY;
11
#else
12
#  ifdef _MSC_VER
13
#define MVM_NUM_POSINF  (DBL_MAX+DBL_MAX)
14
#define MVM_NUM_NEGINF -(DBL_MAX+DBL_MAX)
15
#  else
16
static const MVMnum64 MVM_NUM_POSINF =  1.0 / 0.0;
17
static const MVMnum64 MVM_NUM_NEGINF = -1.0 / 0.0;
18
#  endif
19
#endif
20
21
#if defined(NAN) && !defined(_AIX)
22
static const MVMnum64 MVM_NUM_NAN = NAN;
23
#else
24
#  ifdef _MSC_VER
25
#define MVM_NUM_NAN (MVM_NUM_POSINF-MVM_NUM_POSINF)
26
#  else
27
static const MVMnum64 MVM_NUM_NAN = 0.0 / 0.0;
28
#  endif
29
#endif
30
31
186
MVMint64 MVM_num_isnanorinf(MVMThreadContext *tc, MVMnum64 n) {
32
185
    return n == MVM_NUM_POSINF || n == MVM_NUM_NEGINF || n != n;
33
186
}
34
35
20.5k
MVMnum64 MVM_num_posinf(MVMThreadContext *tc) {
36
20.5k
    return MVM_NUM_POSINF;
37
20.5k
}
38
39
20.5k
MVMnum64 MVM_num_neginf(MVMThreadContext *tc) {
40
20.5k
    return MVM_NUM_NEGINF;
41
20.5k
}
42
43
3
MVMnum64 MVM_num_nan(MVMThreadContext *tc) {
44
3
    return MVM_NUM_NAN;
45
3
}