class
NumberRepresents a constant value on an arbitrary number of bits.
Contents
This class is mainly intended to be used internally by Maat's engine. If the number of bits is inferior or equal to 64, the value will be stored in a cst_t variable. If the number of bits is superior to 64, the classes uses a multiprecision integer from the GMP library
❱ Base classes
- class Serializable
- Virtual interface that serializable classes must implement.
❱ Constructors, destructors, conversion operators
❱ Public functions
- auto operator=(const Number& x) -> Number& defaulted
- Assignement.
- auto operator=(Number&& x) -> Number& defaulted
- Move Assignement.
-
void set_cst(cst_
t val) - Set the number to simple value 'val'.
-
void set_mpz(cst_
t val) - Set the number to multiprecision value 'val'.
- void set_mpz(const std::string& val, int base)
- Set the number to a multiprevision value 'val'.
-
void set(cst_
t val) - Set the number to value 'val' without changing its current type (simple integer or mpz)
-
auto get_cst() const -> cst_
t - Get the number value as a 'cst_t', truncate if needed.
-
auto get_ucst() const -> ucst_
t - Get the number value as a 'ucst_t', truncate if needed.
- auto less_than(const Number& other) const -> bool
- Return true if this number is unsigned less than 'other'.
- auto lessequal_than(const Number& other) const -> bool
- Return true if this number is unsigned less or equal than 'other'.
- auto sless_than(const Number& other) const -> bool
- Return true if this number is signed less than 'other'.
- auto slessequal_than(const Number& other) const -> bool
- Return true if this number is signed less or equal than 'other'.
- auto equal_to(const Number& other) const -> bool
- Return true if this number is equal to 'other'.
- auto get_bit(unsigned int idx) const -> int
- Return the value (0 or 1) of the bit 'idx' in the number.
-
auto class_uid() const -> serial::
uid_t virtual - Return the class uid (see ClassId enum)
-
void dump(serial::
Serializer&) const virtual - Dump the object contents in a serializer stream.
-
void load(serial::
Deserializer&) virtual - Restore an object from a deserializer stream.
❱ Friends
- auto operator<<(std::ostream& os, const Number& n) -> std::ostream&
- Print number to a stream.