Skip to content

Commit

Permalink
Share INFINITY def between files that use it
Browse files Browse the repository at this point in the history
  • Loading branch information
zoffixznet committed Apr 10, 2018
1 parent 4234ab5 commit 96e432d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 34 deletions.
9 changes: 2 additions & 7 deletions src/math/bigintops.c
@@ -1,11 +1,6 @@
#include "moar.h"
#include <math.h>

#if defined(_MSC_VER) && ! defined(INFINITY)
#include <float.h>
#define INFINITY (DBL_MAX + DBL_MAX)
#endif

#ifndef MANTISSA_BITS_IN_DOUBLE
#define MANTISSA_BITS_IN_DOUBLE 53
#endif
Expand Down Expand Up @@ -956,9 +951,9 @@ MVMnum64 MVM_bigint_div_num(MVMThreadContext *tc, MVMObject *a, MVMObject *b) {
mp_clamp(ib);
if (ib->used == 0) { /* zero-denominator special case */
if (ia->sign == MP_NEG)
c = -INFINITY;
c = MVM_NUM_NEGINF;
else
c = INFINITY;
c = MVM_NUM_POSINF;
/*
* we won't have NaN case here, since the branch requires at
* least one bigint to be big
Expand Down
27 changes: 0 additions & 27 deletions src/math/num.c
@@ -1,33 +1,6 @@
#include "moar.h"
#include <math.h>

#ifdef _WIN32
#include <float.h>
#endif

#if defined(INFINITY) && !defined(_AIX)
static const MVMnum64 MVM_NUM_POSINF = INFINITY;
static const MVMnum64 MVM_NUM_NEGINF = -INFINITY;
#else
# ifdef _MSC_VER
#define MVM_NUM_POSINF (DBL_MAX+DBL_MAX)
#define MVM_NUM_NEGINF -(DBL_MAX+DBL_MAX)
# else
static const MVMnum64 MVM_NUM_POSINF = 1.0 / 0.0;
static const MVMnum64 MVM_NUM_NEGINF = -1.0 / 0.0;
# endif
#endif

#if defined(NAN) && !defined(_AIX)
static const MVMnum64 MVM_NUM_NAN = NAN;
#else
# ifdef _MSC_VER
#define MVM_NUM_NAN (MVM_NUM_POSINF-MVM_NUM_POSINF)
# else
static const MVMnum64 MVM_NUM_NAN = 0.0 / 0.0;
# endif
#endif

MVMint64 MVM_num_isnanorinf(MVMThreadContext *tc, MVMnum64 n) {
return n == MVM_NUM_POSINF || n == MVM_NUM_NEGINF || n != n;
}
Expand Down
32 changes: 32 additions & 0 deletions src/math/num.h
@@ -1,4 +1,36 @@
#ifndef MATH_NUM_H
#define MATH_NUM_H

#ifdef _WIN32
#include <float.h>
#endif

#if defined(INFINITY) && !defined(_AIX)
static const MVMnum64 MVM_NUM_POSINF = INFINITY;
static const MVMnum64 MVM_NUM_NEGINF = -INFINITY;
#else
# ifdef _MSC_VER
#define MVM_NUM_POSINF (DBL_MAX+DBL_MAX)
#define MVM_NUM_NEGINF -(DBL_MAX+DBL_MAX)
# else
static const MVMnum64 MVM_NUM_POSINF = 1.0 / 0.0;
static const MVMnum64 MVM_NUM_NEGINF = -1.0 / 0.0;
# endif
#endif

#if defined(NAN) && !defined(_AIX)
static const MVMnum64 MVM_NUM_NAN = NAN;
#else
# ifdef _MSC_VER
#define MVM_NUM_NAN (MVM_NUM_POSINF-MVM_NUM_POSINF)
# else
static const MVMnum64 MVM_NUM_NAN = 0.0 / 0.0;
# endif
#endif

MVMint64 MVM_num_isnanorinf(MVMThreadContext *tc, MVMnum64 n);
MVMnum64 MVM_num_posinf(MVMThreadContext *tc);
MVMnum64 MVM_num_neginf(MVMThreadContext *tc);
MVMnum64 MVM_num_nan(MVMThreadContext *tc);

#endif

0 comments on commit 96e432d

Please sign in to comment.