From 6aa9264477c261344415ad57933aa2116c5299db Mon Sep 17 00:00:00 2001 From: Eric Frias Date: Tue, 30 Jun 2015 10:26:44 -0400 Subject: [PATCH] Make asset precision uint8 everywhere (it was defined as a uint64 and referenced as a signed short in some places, I think these were artifacts from when precision was stored as 10^x instead of x. --- libraries/chain/asset_object.cpp | 4 ++-- libraries/chain/include/graphene/chain/asset_object.hpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/chain/asset_object.cpp b/libraries/chain/asset_object.cpp index 3f94479a..57c1bfff 100644 --- a/libraries/chain/asset_object.cpp +++ b/libraries/chain/asset_object.cpp @@ -145,7 +145,7 @@ asset asset_object::amount_from_string(string amount_string) const share_type satoshis = 0; share_type scaled_precision = 1; - for( short i = 0; i < precision; ++i ) + for( uint8_t i = 0; i < precision; ++i ) scaled_precision *= 10; const auto decimal_pos = amount_string.find( '.' ); @@ -178,7 +178,7 @@ asset asset_object::amount_from_string(string amount_string) const string asset_object::amount_to_string(share_type amount) const { share_type scaled_precision = 1; - for( short i = 0; i < precision; ++i ) + for( uint8_t i = 0; i < precision; ++i ) scaled_precision *= 10; assert(scaled_precision > 0); diff --git a/libraries/chain/include/graphene/chain/asset_object.hpp b/libraries/chain/include/graphene/chain/asset_object.hpp index 9f902d0b..a1435d47 100644 --- a/libraries/chain/include/graphene/chain/asset_object.hpp +++ b/libraries/chain/include/graphene/chain/asset_object.hpp @@ -110,8 +110,8 @@ namespace graphene { namespace chain { /// Ticker symbol for this asset, i.e. "USD" string symbol; - /// Maximum number of digits after the decimal point - uint64_t precision; + /// Maximum number of digits after the decimal point (must be <= 12) + uint8_t precision; /// ID of the account which issued this asset. account_id_type issuer;