From 51033bcb12ba4a39587a72826599d938ab545ca5 Mon Sep 17 00:00:00 2001 From: theoretical Date: Tue, 3 Feb 2015 11:22:02 -0500 Subject: [PATCH] real128: Implement from_fixed() to initialize real128 from fixed point value --- include/fc/real128.hpp | 2 ++ src/real128.cpp | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/include/fc/real128.hpp b/include/fc/real128.hpp index 3b66060..bfa288c 100644 --- a/include/fc/real128.hpp +++ b/include/fc/real128.hpp @@ -24,6 +24,8 @@ namespace fc { real128& operator -= ( const real128& o ); real128& operator /= ( const real128& o ); real128& operator *= ( const real128& o ); + + static real128 from_fixed( const uint128& fixed ); uint64_t to_uint64()const; diff --git a/src/real128.cpp b/src/real128.cpp index 3f5b431..0f0b759 100644 --- a/src/real128.cpp +++ b/src/real128.cpp @@ -112,6 +112,13 @@ namespace fc return number; } + + real128 real128::from_fixed( const uint128& fixed ) + { + real128 result; + result.fixed = fixed; + return result; + } void to_variant( const real128& var, variant& vo ) {