Make conversions from boost's uint128_t to builtin int64_t explicit, without these
the compiler prefers to convert through operator bool yielding either 1 or 0.
This commit is contained in:
parent
837e4f254e
commit
9c650bddb0
1 changed files with 6 additions and 6 deletions
|
|
@ -72,16 +72,16 @@ namespace graphene { namespace chain {
|
|||
if( a.asset_id == b.base.asset_id )
|
||||
{
|
||||
FC_ASSERT( b.base.amount.value > 0 );
|
||||
auto result = (uint128_t(a.amount.value) * b.quote.amount.value)/b.base.amount.value;
|
||||
uint128_t result = (uint128_t(a.amount.value) * b.quote.amount.value)/b.base.amount.value;
|
||||
FC_ASSERT( result <= GRAPHENE_MAX_SHARE_SUPPLY );
|
||||
return asset( result, b.quote.asset_id );
|
||||
return asset( result.convert_to<int64_t>(), b.quote.asset_id );
|
||||
}
|
||||
else if( a.asset_id == b.quote.asset_id )
|
||||
{
|
||||
FC_ASSERT( b.quote.amount.value > 0 );
|
||||
auto result = (uint128_t(a.amount.value) * b.base.amount.value)/b.quote.amount.value;
|
||||
uint128_t result = (uint128_t(a.amount.value) * b.base.amount.value)/b.quote.amount.value;
|
||||
FC_ASSERT( result <= GRAPHENE_MAX_SHARE_SUPPLY );
|
||||
return asset( result, b.base.asset_id );
|
||||
return asset( result.convert_to<int64_t>(), b.base.asset_id );
|
||||
}
|
||||
FC_THROW_EXCEPTION( fc::assert_exception, "invalid asset * price", ("asset",a)("price",b) );
|
||||
}
|
||||
|
|
@ -121,7 +121,7 @@ namespace graphene { namespace chain {
|
|||
while( cp.numerator() > GRAPHENE_MAX_SHARE_SUPPLY || cp.denominator() > GRAPHENE_MAX_SHARE_SUPPLY )
|
||||
cp = boost::rational<int128_t>( (cp.numerator() >> 1)+1, (cp.denominator() >> 1)+1 );
|
||||
|
||||
return ~(asset( cp.numerator(), debt.asset_id ) / asset( cp.denominator(), collateral.asset_id ));
|
||||
return ~(asset( cp.numerator().convert_to<int64_t>(), debt.asset_id ) / asset( cp.denominator().convert_to<int64_t>(), collateral.asset_id ));
|
||||
} FC_CAPTURE_AND_RETHROW( (debt)(collateral)(collateral_ratio) ) }
|
||||
|
||||
bool price::is_null() const { return *this == price(); }
|
||||
|
|
@ -169,7 +169,7 @@ namespace graphene { namespace chain {
|
|||
while( cp.numerator() > GRAPHENE_MAX_SHARE_SUPPLY || cp.denominator() > GRAPHENE_MAX_SHARE_SUPPLY )
|
||||
cp = boost::rational<int128_t>( (cp.numerator() >> 1)+(cp.numerator()&1), (cp.denominator() >> 1)+(cp.denominator()&1) );
|
||||
|
||||
return (asset( cp.numerator(), settlement_price.base.asset_id ) / asset( cp.denominator(), settlement_price.quote.asset_id ));
|
||||
return (asset( cp.numerator().convert_to<int64_t>(), settlement_price.base.asset_id ) / asset( cp.denominator().convert_to<int64_t>(), settlement_price.quote.asset_id ));
|
||||
}
|
||||
|
||||
// compile-time table of powers of 10 using template metaprogramming
|
||||
|
|
|
|||
Loading…
Reference in a new issue