Skip to content

Commit

Permalink
Refactor RealFunctions
Browse files Browse the repository at this point in the history
  • Loading branch information
fintarin committed Aug 1, 2023
1 parent 7a66a65 commit a7bff04
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/fintamath/numbers/RealFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "fintamath/exceptions/UndefinedException.hpp"

using namespace boost::multiprecision;
using boost::multiprecision::cpp_dec_float_100;

namespace fintamath {

Expand All @@ -26,7 +26,7 @@ Real pow(const Real &lhs, const Real &rhs) {
throw UndefinedBinaryOperatorException("^", lhs.toString(), rhs.toString());
}

cpp_dec_float_100 res(pow(lhs.getBackend(), rhs.getBackend()));
cpp_dec_float_100 res = pow(lhs.getBackend(), rhs.getBackend());

if (res.backend().isinf() || res.backend().isnan()) {
throw UndefinedBinaryOperatorException("^", lhs.toString(), rhs.toString());
Expand Down Expand Up @@ -121,7 +121,7 @@ Real asin(const Real &rhs) {
}

Real acos(const Real &rhs) {
cpp_dec_float_100 res(acos(rhs.getBackend()));
cpp_dec_float_100 res = acos(rhs.getBackend());

if (res.backend().isnan()) {
throw UndefinedFunctionException("acos", {rhs.toString()});
Expand Down Expand Up @@ -199,11 +199,13 @@ Real acoth(const Real &rhs) {
}

Real getE() {
return {cpp_dec_float_100(default_ops::get_constant_e<cpp_dec_float_100::backend_type>())};
using boost::multiprecision::default_ops::get_constant_e;
return {cpp_dec_float_100(get_constant_e<cpp_dec_float_100::backend_type>())};
}

Real getPi() {
return {cpp_dec_float_100(default_ops::get_constant_pi<cpp_dec_float_100::backend_type>())};
using boost::multiprecision::default_ops::get_constant_pi;
return {cpp_dec_float_100(get_constant_pi<cpp_dec_float_100::backend_type>())};
}

}

0 comments on commit a7bff04

Please sign in to comment.