From 323d59b054ff19d7091ba3129e81f225e7fe1dfb Mon Sep 17 00:00:00 2001 From: theoretical Date: Tue, 3 Feb 2015 11:31:20 -0500 Subject: [PATCH] real128: Rename PRECISION to FC_REAL128_PRECISION and expose it globally --- include/fc/real128.hpp | 2 ++ src/real128.cpp | 14 ++++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/fc/real128.hpp b/include/fc/real128.hpp index bfa288c..98033b5 100644 --- a/include/fc/real128.hpp +++ b/include/fc/real128.hpp @@ -1,5 +1,7 @@ #include +#define FC_REAL128_PRECISION (uint64_t(1000000) * uint64_t(1000000) * uint64_t(1000000)) + namespace fc { class variant; diff --git a/src/real128.cpp b/src/real128.cpp index 0f0b759..c83336e 100644 --- a/src/real128.cpp +++ b/src/real128.cpp @@ -4,18 +4,16 @@ #include #include -#define PRECISION (uint64_t(1000000) * uint64_t(1000000) * uint64_t(1000000)) - namespace fc { uint64_t real128::to_uint64()const { - return (fixed/PRECISION).to_uint64(); + return (fixed/ FC_REAL128_PRECISION).to_uint64(); } real128::real128( uint64_t integer ) { - fixed = uint128(integer) * PRECISION; + fixed = uint128(integer) * FC_REAL128_PRECISION; } real128& real128::operator += ( const real128& o ) { @@ -34,7 +32,7 @@ namespace fc fc::bigint self(fixed); fc::bigint other(o.fixed); - self *= PRECISION; + self *= FC_REAL128_PRECISION; self /= other; fixed = self; @@ -46,7 +44,7 @@ namespace fc fc::bigint self(fixed); fc::bigint other(o.fixed); self *= other; - self /= PRECISION; + self /= FC_REAL128_PRECISION; fixed = self; return *this; } FC_CAPTURE_AND_RETHROW( (*this)(o) ) } @@ -102,9 +100,9 @@ namespace fc real128::operator std::string()const { std::stringstream ss; - ss << std::string(fixed / PRECISION); + ss << std::string(fixed / FC_REAL128_PRECISION); ss << '.'; - auto frac = (fixed % PRECISION) + PRECISION; + auto frac = (fixed % FC_REAL128_PRECISION) + FC_REAL128_PRECISION; ss << std::string( frac ).substr(1); auto number = ss.str();