Loading...
Searching...
No Matches
arith_tools.h File Reference
+ Include dependency graph for arith_tools.h:
Go to the source code of this file.
Numerical cast provides a unified way of converting from one numerical type to another.
More...
Convert expression to mp_integer.
More...
Convert mp_integer or expr to any integral type.
More...
Convert a constant expression expr to an arbitrary-precision integer.
Converts an expression to any integral type.
Convert an mp_integer to integral type Target An invariant will fail if the conversion is not possible.
Convert an expression to integral type Target An invariant will fail if the conversion is not possible.
ceil(log2(size))
A multi-precision implementation of the power operator.
Get a bit with given index from bit-vector representation.
construct a bit-vector representation from a functor
convert an integer to bit-vector representation with given width This uses two's complement for negative numbers.
convert a bit-vector representation (possibly signed) to integer
Function Documentation
◆ address_bits()
◆ bvrep2integer()
convert a bit-vector representation (possibly signed) to integer
Definition at line 426 of file arith_tools.cpp.
◆ from_integer()
◆ get_bvrep_bit()
std::size_t
width,
std::size_t
bit_index
)
Get a bit with given index from bit-vector representation.
- Parameters
-
src the bitvector representation
width the number of bits in the bitvector
bit_index index (0 is the least significant)
Definition at line 286 of file arith_tools.cpp.
◆ integer2bvrep()
convert an integer to bit-vector representation with given width This uses two's complement for negative numbers.
If the value is out of range, it is 'wrapped around'.
Definition at line 404 of file arith_tools.cpp.
◆ is_power_of_two()
◆ make_bvrep()
construct a bit-vector representation from a functor
- Parameters
-
width the width of the bit-vector
f the functor – the parameter is the bit index
- Returns
- new bitvector representation
Definition at line 330 of file arith_tools.cpp.
◆ mp_max()
◆ mp_min()
◆ numeric_cast()
Converts an expression to any integral type.
- Template Parameters
-
Target type to convert to
- Parameters
-
arg expression to convert
- Returns
- optional integer of type Target if conversion is possible, empty optional otherwise.
Definition at line 124 of file arith_tools.h.
◆ numeric_cast_v() [1/2]
Convert an expression to integral type Target An invariant will fail if the conversion is not possible.
- Template Parameters
-
Target type to convert to
- Parameters
-
arg constant expression
- Returns
- value of type Target
Definition at line 148 of file arith_tools.h.
◆ numeric_cast_v() [2/2]
Convert an mp_integer to integral type Target An invariant will fail if the conversion is not possible.
- Template Parameters
-
Target type to convert to
- Parameters
-
arg mp_integer
- Returns
- value of type Target
Definition at line 135 of file arith_tools.h.
◆ power()
A multi-precision implementation of the power operator.
- parameters: Two mp_integers, base and exponent
- Returns
- One mp_integer with the value base^{exponent}
Definition at line 219 of file arith_tools.cpp.
◆ to_integer()
Convert a constant expression expr to an arbitrary-precision integer.
- Parameters
-
expr Source expression
[out] int_value Integer value (only modified if conversion succeeds)
- Returns
- False if, and only if, the conversion was successful.
Definition at line 21 of file arith_tools.cpp.