bag.util.math
Module Contents
Classes
A class that represents a half integer. |
|
A simple calculator. |
- class bag.util.math.HalfInt(dbl_val: Any)[source]
Bases:
numbers.Integral
A class that represents a half integer.
- __divmod__(other)[source]
divmod(self, other): The pair (self // other, self % other).
Sometimes this can be computed faster than the pair of operations.
- __pow__(other, modulus=None)[source]
self ** exponent % modulus, but maybe faster.
Accept the modulus argument if you want to support the 3-argument version of pow(). Raise a TypeError if exponent < 0 or any argument isn’t Integral. Otherwise, just implement the 2-argument version described in Complex.
- __rdivmod__(other)[source]
divmod(other, self): The pair (self // other, self % other).
Sometimes this can be computed faster than the pair of operations.
- __round__(ndigits=0)[source]
Rounds self to ndigits decimal places, defaulting to 0.
If ndigits is omitted or None, returns an Integral, otherwise returns a Real. Rounds half toward even.
- class bag.util.math.Calculator(namespace: Mapping[str, Any])[source]
Bases:
ast.NodeVisitor
A simple calculator.
Modified from: https://stackoverflow.com/questions/33029168/how-to-calculate-an-equation-in-a-string-python
user mgilson said in a comment that he agrees to distribute code with Apache 2.0 license.