13 char*
write_decimal(
char* begin,
char* end,
bool dry_run,
uint64_t number, uint8_t num_decimal_places,
bool negative );
90 asset operator-()
const {
104 eosio::check( a.symbol ==
symbol,
"attempt to subtract asset with different symbol" );
160 asset& operator*=( int64_t a ) {
161 int128_t tmp = (int128_t)
amount * (int128_t)a;
176 friend asset operator*(
const asset& a, int64_t b ) {
190 friend asset operator*( int64_t b,
const asset& a ) {
204 asset& operator/=( int64_t a ) {
206 eosio::check( !(
amount == std::numeric_limits<int64_t>::min() && a == -1),
"signed division overflow" );
218 friend asset operator/(
const asset& a, int64_t b ) {
232 friend int64_t operator/(
const asset& a,
const asset& b ) {
234 eosio::check( a.symbol == b.symbol,
"attempt to divide assets with different symbol" );
235 return a.amount / b.amount;
248 eosio::check( a.symbol == b.symbol,
"comparison of assets with different symbols is not allowed" );
249 return a.amount == b.amount;
275 eosio::check( a.symbol == b.symbol,
"comparison of assets with different symbols is not allowed" );
276 return a.amount < b.amount;
289 eosio::check( a.symbol == b.symbol,
"comparison of assets with different symbols is not allowed" );
290 return a.amount <= b.amount;
303 eosio::check( a.symbol == b.symbol,
"comparison of assets with different symbols is not allowed" );
304 return a.amount > b.amount;
317 eosio::check( a.symbol == b.symbol,
"comparison of assets with different symbols is not allowed" );
318 return a.amount >= b.amount;
336 bool negative = (
amount < 0);
342 int sufficient_size = std::max(
static_cast<int>(precision), 19) + 11;
343 if( dry_run || (begin + sufficient_size < begin) || (begin + sufficient_size > end) ) {
344 char* start_of_symbol =
write_decimal( begin, end,
true, abs_amount, precision, negative ) + 1;
346 if( dry_run || (actual_end < begin) || (actual_end > end) )
return actual_end;
349 char* end_of_number =
write_decimal( begin, end,
false, abs_amount, precision, negative );
350 *(end_of_number) =
' ';
366 return {buffer, end};
381 printl( buffer, (end-buffer) );
441 eosio::check( a.contract == b.contract,
"type mismatch" );
442 return {a.quantity - b.quantity, a.contract};
447 eosio::check( a.contract == b.contract,
"type mismatch" );
448 return {a.quantity + b.quantity, a.contract};
453 eosio::check( a.contract == b.contract,
"type mismatch" );
454 a.quantity += b.quantity;
460 eosio::check( a.contract == b.contract,
"type mismatch" );
461 a.quantity -= b.quantity;
473 return {a.quantity * b, a.contract};
478 return {a * b.quantity, b.contract};
483 eosio::check( a.contract == b.contract,
"type mismatch" );
484 return a.quantity / b.quantity;
495 return {a.quantity / b, a.contract};
501 eosio::check( a.contract == b.contract,
"type mismatch" );
502 return a.quantity < b.quantity;
507 eosio::check( a.contract == b.contract,
"type mismatch" );
508 return a.quantity > b.quantity;
513 return std::tie(a.quantity, a.contract) == std::tie(b.quantity, b.contract);
518 return std::tie(a.quantity, a.contract) != std::tie(b.quantity, b.contract);
523 eosio::check( a.contract == b.contract,
"type mismatch" );
524 return a.quantity <= b.quantity;
529 eosio::check( a.contract == b.contract,
"type mismatch" );
530 return a.quantity >= b.quantity;