aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_basic
diff options
context:
space:
mode:
authorAlexander Blair <snipa@jagtech.io>2020-02-28 19:48:10 -0800
committerAlexander Blair <snipa@jagtech.io>2020-02-28 19:48:11 -0800
commit4371ac4265b7abe425697a31f9455d863db04d6b (patch)
tree55640d795da21941ea37d7bd787479bd6e6b0f5c /src/cryptonote_basic
parentMerge pull request #6224 (diff)
parentprint_coinbase_tx_sum now supports 128 bits sums (diff)
downloadmonero-4371ac4265b7abe425697a31f9455d863db04d6b.tar.xz
Merge pull request #6225
987c3139 print_coinbase_tx_sum now supports 128 bits sums (moneromooo-monero)
Diffstat (limited to 'src/cryptonote_basic')
-rw-r--r--src/cryptonote_basic/cryptonote_format_utils.cpp18
-rw-r--r--src/cryptonote_basic/cryptonote_format_utils.h2
2 files changed, 18 insertions, 2 deletions
diff --git a/src/cryptonote_basic/cryptonote_format_utils.cpp b/src/cryptonote_basic/cryptonote_format_utils.cpp
index 138cf49f4..651d61b06 100644
--- a/src/cryptonote_basic/cryptonote_format_utils.cpp
+++ b/src/cryptonote_basic/cryptonote_format_utils.cpp
@@ -996,17 +996,31 @@ namespace cryptonote
}
}
//---------------------------------------------------------------
- std::string print_money(uint64_t amount, unsigned int decimal_point)
+ static void insert_money_decimal_point(std::string &s, unsigned int decimal_point)
{
if (decimal_point == (unsigned int)-1)
decimal_point = default_decimal_point;
- std::string s = std::to_string(amount);
if(s.size() < decimal_point+1)
{
s.insert(0, decimal_point+1 - s.size(), '0');
}
if (decimal_point > 0)
s.insert(s.size() - decimal_point, ".");
+ }
+ //---------------------------------------------------------------
+ std::string print_money(uint64_t amount, unsigned int decimal_point)
+ {
+ std::string s = std::to_string(amount);
+ insert_money_decimal_point(s, decimal_point);
+ return s;
+ }
+ //---------------------------------------------------------------
+ std::string print_money(const boost::multiprecision::uint128_t &amount, unsigned int decimal_point)
+ {
+ std::stringstream ss;
+ ss << amount;
+ std::string s = ss.str();
+ insert_money_decimal_point(s, decimal_point);
return s;
}
//---------------------------------------------------------------
diff --git a/src/cryptonote_basic/cryptonote_format_utils.h b/src/cryptonote_basic/cryptonote_format_utils.h
index 29e4def64..8ed3b0b43 100644
--- a/src/cryptonote_basic/cryptonote_format_utils.h
+++ b/src/cryptonote_basic/cryptonote_format_utils.h
@@ -38,6 +38,7 @@
#include "crypto/crypto.h"
#include "crypto/hash.h"
#include <unordered_map>
+#include <boost/multiprecision/cpp_int.hpp>
namespace epee
{
@@ -139,6 +140,7 @@ namespace cryptonote
unsigned int get_default_decimal_point();
std::string get_unit(unsigned int decimal_point = -1);
std::string print_money(uint64_t amount, unsigned int decimal_point = -1);
+ std::string print_money(const boost::multiprecision::uint128_t &amount, unsigned int decimal_point = -1);
//---------------------------------------------------------------
template<class t_object>
bool t_serializable_object_from_blob(t_object& to, const blobdata& b_blob)