Safeheron-SGX-Native-Development-Framework v1.2.0
Loading...
Searching...
No Matches
ssgx::decimal_t::Precision Class Reference

Precision control class The Precision class is used to configure the number of digits and rounding type of the BigDecimal calculation result. More...

#include <ssgx_decimal_t.h>

Public Member Functions

 Precision (RoundType round_type, int scale)
 Constructor.
 
 ~Precision ()
 Destruction.
 

Friends

class BigDecimal
 

Detailed Description

Precision control class The Precision class is used to configure the number of digits and rounding type of the BigDecimal calculation result.

Constructor & Destructor Documentation

◆ Precision()

ssgx::decimal_t::Precision::Precision ( RoundType round_type,
int scale )

Constructor.

Parameters
[in]round_typeThe rounding type, one of RoundType value.
[in]scale> 0, Keep significant digits up to a certain decimal place = 0, The result will be kept as an integer < 0, Keep significant digits up to a certain integer place
Note
Parameter scale must less than SSGX_MAX_PREC(99), otherwise an exception will occur.
@par Examples
@codeotherwise an exception will occur
BigDecimal a("123.456");
BigDecimal b("2.2");
BigDecimal result;
Precision prec1(ROUND_HALF_UP, 2);
Precision prec2(ROUND_HALF_UP, 0);
Precision prec3(ROUND_HALF_UP, -2);
// Use the default precision
result = a.Multiply(b); // 271.6032
// Round to two decimal places
result = a.Multiply(b, prec1); // 271.60
// Value kept as an integer
result = a.Multiply(b, prec2); // 272
// Significant digits up to the hundreds place
result = a.Multiply(b, prec3); // 300
High precision big number class This class implements the basic calculation and comparison operations...
Definition ssgx_decimal_t.h:125
BigDecimal Multiply(const BigDecimal &num) const
Multiplication of Numbers. Return a new BigDecimal object which equal to (*this) * num.
Precision control class The Precision class is used to configure the number of digits and rounding ty...
Definition ssgx_decimal_t.h:57

◆ ~Precision()

ssgx::decimal_t::Precision::~Precision ( )

Destruction.

Friends And Related Symbol Documentation

◆ BigDecimal

friend class BigDecimal
friend

The documentation for this class was generated from the following file: