Numbers#
The cake library provides basic number classes which interact and function the same as regular python number classes.
Number#
- class cake.Number(_Number__value: N, /)[source]#
Bases:
NumberBasic class for creating different types of numbers, this class can be treated as a normal number like in python.
Tip
To retrieve the actual value of the class, use
Number.valuefrom cake import Number, Variable x = 5 x += Number(10) ## x is now an Integral not a Number a = Variable('a') x = x + a ## x is now an Expression ## x = Expr(Integral(15), Variable('a')) ## which can be represented as f(x) = 15 + a
Complex#
Real#
- class cake.Real(value: N, /)[source]#
-
Represents a generic real number
>>> Real(1.5) == 1.5 True >>> Real(Integral(5)) = 5 True
- as_integer_ratio()[source]#
Return integer ratio.
Return a pair of integers, whose ratio is exactly equal to the original float and with a positive denominator.
Raise OverflowError on infinities and a ValueError on NaNs.
>>> (10.0).as_integer_ratio() (10, 1) >>> (0.0).as_integer_ratio() (0, 1) >>> (-.25).as_integer_ratio() (-1, 4)