18 BN_CTX_free(
static_cast<BN_CTX *
> (ctx));
36 VERIFY(BN_copy(
static_cast<BIGNUM *
> (
value),
static_cast<BIGNUM *
> (copy.
value)));
40 VERIFY(BN_copy(
static_cast<BIGNUM *
> (
value),
static_cast<BIGNUM *
> (copy.
value)));
46 BN_set_word(
static_cast<BIGNUM *
> (
value), -var);
47 BN_set_negative(
static_cast<BIGNUM *
> (
value), -1);
50 BN_set_word(
static_cast<BIGNUM *
> (
value), var);
67 BN_free(
static_cast<BIGNUM *
> (
value));
77 int64_t
result = BN_get_word(
static_cast<BIGNUM *
> (
value));
78 if (BN_is_negative(
static_cast<BIGNUM *
> (
value))) {
89 int num_bits = BN_num_bits(
static_cast<BIGNUM *
> (
value));
102 BN_lshift(
static_cast<BIGNUM *
> (divider.
value),
static_cast<BIGNUM *
> (one.
value), num_bits - 52);
105 temp.
div(divider, remander);
110 result *= std::pow(2, num_bits - 52);
123 BIGNUM * temp =
static_cast<BIGNUM *
> (
value);
124 if (!BN_dec2bn(&temp, str.begin())) {
125 LOG_RUNTIME(
"Fail create BinNum from string '%s'!", str.begin());
127 value = (
void *) temp;
132 char * number_str = BN_bn2dec(
static_cast<BIGNUM *
> (
value));
133 std::string
result(number_str);
134 OPENSSL_free(number_str);
141 if (!BN_add(
static_cast<BIGNUM *
> (
value),
static_cast<BIGNUM *
> (temp.
value),
static_cast<BIGNUM *
> (val.
value))) {
149 if (!BN_sub(
static_cast<BIGNUM *
> (
value),
static_cast<BIGNUM *
> (temp.
value),
static_cast<BIGNUM *
> (val.
value))) {
158 if (!BN_mul(
static_cast<BIGNUM *
> (
value),
static_cast<BIGNUM *
> (temp.
value),
static_cast<BIGNUM *
> (val.
value),
static_cast<BN_CTX *
> (ctx.
ctx))) {
167 if (!BN_div(
static_cast<BIGNUM *
> (
value),
static_cast<BIGNUM *
> (rem.
value),
static_cast<BIGNUM *
> (temp.
value),
static_cast<BIGNUM *
> (val.
value),
static_cast<BN_CTX *
> (ctx.
ctx))) {
175 BN_one(
static_cast<BIGNUM *
> (
value));
180 BN_zero(
static_cast<BIGNUM *
> (
value));
185 return BN_get_word(
static_cast<BIGNUM *
> (
value)) ==
static_cast<uint64_t
>(~0);
190 return BN_is_zero(
static_cast<BIGNUM *
> (
value));
195 return BN_is_one(
static_cast<BIGNUM *
> (
value));
200 return BN_is_negative(
static_cast<BIGNUM *
> (
value));
220 set_(numerator, denominator);
224 std::shared_ptr<Rational>
result = std::make_shared<Rational>(*
this);
244 LOG_RUNTIME(
"Denominator must be different from zero!");
261 LOG_RUNTIME(
"Denominator must be different from zero!");
Rational & operator-=(const Rational &rational)
std::string GetAsString() const
Rational & op_lshift_set(const Rational &)
Rational & op_pow_(const Rational &rational)
Rational & op_div_ceil_(Rational &rational)
bool op_equal(const Rational &rational) const
std::shared_ptr< Rational > clone() const
Rational & operator*=(const Rational &rational)
Rational & op_rshift_set(const Rational &)
Rational & operator^=(const Rational &)
const Rational & op_rrshift_set(const Rational &)
Rational & operator|=(const Rational &)
Rational & operator/=(const Rational &rational)
Rational & operator%=(const Rational &rational)
int64_t GetAsBoolean() const
int op_compare(const Rational &rational) const
Rational & set_(const int64_t value)
Rational & operator+=(const Rational &rational)
int64_t GetAsInteger() const
double GetAsNumber() const
#define LOG_RUNTIME(format,...)
#define ASSERT(condition)
BigNum & div(const BigNum &val, BigNum &rem)
bool SetFromString(const std::string_view str)
BigNum & operator=(const BigNum &var)
BigNum & mul(const BigNum &val)
std::string GetAsString() const
BigNum & sub(const BigNum &val)
double GetAsNumber() const
BigNum & add(const BigNum &val)
int64_t GetAsInteger() const
BigNum & set_(const BigNum ©)