Skip to content

Commit

Permalink
Merge pull request oxeanbits#10 from Victorcorcos/improve_round_preci…
Browse files Browse the repository at this point in the history
…sion

Define long double and use it for 9 precision approximations
  • Loading branch information
niltonvasques authored May 18, 2018
2 parents d312641 + cbe8920 commit 9120f07
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 4 additions & 0 deletions parser/mpDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@
/** \brief Floating point type used by the parser. */
#define MUP_FLOAT_TYPE double

/** \brief Long double type used by the parser for high precision values. */
#define MUP_LDOUBLE_TYPE long double

/** \brief Integer type used by the parser. */
#define MUP_INT_TYPE int

/** \brief Verifies whether a given condition is met.
Expand Down
4 changes: 2 additions & 2 deletions parser/mpFuncNonCmplx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
MUP_NAMESPACE_START

// Auxiliary Functions
double round(double number, int precision) {
int decimals = std::pow(10, precision);
double round(long_double_type number, int_type precision) {
int_type decimals = std::pow(10, precision);
return (std::round(number * decimals)) / decimals;
}

Expand Down
5 changes: 4 additions & 1 deletion parser/mpTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ typedef std::vector<ptr_val_type> val_vec_type;
/** \brief Parser datatype for floating point value. */
typedef MUP_FLOAT_TYPE float_type;

/** \brief Parser datatype for integer valuse. */
/** \brief Parser datatype for long double values (for high precision). */
typedef MUP_LDOUBLE_TYPE long_double_type;

/** \brief Parser datatype for integer values. */
typedef MUP_INT_TYPE int_type;

/** \brief The basic type used for representing complex numbers. */
Expand Down

0 comments on commit 9120f07

Please sign in to comment.