Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
real128.hpp
Go to the documentation of this file.
1#pragma once
2#include <fc/uint128.hpp>
3
4#define FC_REAL128_PRECISION (uint64_t(1000000) * uint64_t(1000000) * uint64_t(1000000))
5
6namespace fc {
7 class variant;
8
14 class real128
15 {
16 public:
17 real128( uint64_t integer = 0);
18 explicit real128( const std::string& str );
19 operator std::string()const;
20
21 friend real128 operator * ( real128 a, const real128& b ) { a *= b; return a; }
22 friend real128 operator / ( real128 a, const real128& b ) { a /= b; return a; }
23 friend real128 operator + ( real128 a, const real128& b ) { a += b; return a; }
24 friend real128 operator - ( real128 a, const real128& b ) { a -= b; return a; }
25
26 real128& operator += ( const real128& o );
27 real128& operator -= ( const real128& o );
28 real128& operator /= ( const real128& o );
29 real128& operator *= ( const real128& o );
30
31 static real128 from_fixed( const uint128& fixed );
32
33 uint64_t to_uint64()const;
34
35 private:
36 uint128 fixed;
37 };
38
39 void to_variant( const real128& var, variant& vo );
40 void from_variant( const variant& var, real128& vo );
41
42 namespace raw
43 {
44 template<typename Stream>
45 inline void pack( Stream& s, const real128& value_to_pack ) { s.write( (char*)&value_to_pack, sizeof(value_to_pack) ); }
46 template<typename Stream>
47 inline void unpack( Stream& s, real128& value_to_unpack ) { s.read( (char*)&value_to_unpack, sizeof(value_to_unpack) ); }
48 }
49
50
51
52} // namespace fc
real128(uint64_t integer=0)
Definition real128.cpp:14
friend real128 operator/(real128 a, const real128 &b)
Definition real128.hpp:22
real128 & operator*=(const real128 &o)
Definition real128.cpp:42
real128 & operator+=(const real128 &o)
Definition real128.cpp:18
friend real128 operator-(real128 a, const real128 &b)
Definition real128.hpp:24
real128 & operator-=(const real128 &o)
Definition real128.cpp:23
real128 & operator/=(const real128 &o)
Definition real128.cpp:29
static real128 from_fixed(const uint128 &fixed)
Definition real128.cpp:114
friend real128 operator+(real128 a, const real128 &b)
Definition real128.hpp:23
uint64_t to_uint64() const
Definition real128.cpp:9
friend real128 operator*(real128 a, const real128 &b)
Definition real128.hpp:21
an implementation of 128 bit unsigned integer
Definition uint128.hpp:22
Concept for reading and writing characters.
void unpack(Stream &s, std::deque< T > &value)
Definition raw.hpp:540
void pack(Stream &s, const std::deque< T > &value)
Definition raw.hpp:531
namespace sysio::chain
Definition authority.cpp:3
void from_variant(const fc::variant &v, sysio::chain::chain_id_type &cid)
void to_variant(const sysio::chain::shared_public_key &var, fc::variant &vo)
Definition authority.cpp:4
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1181
unsigned __int64 uint64_t
Definition stdint.h:136
char * s