N

N(num, relative_error=None)

Create a new Symbolica number from an int, a float, or a string. A floating point number is kept as a float with the same precision as the input, but it can also be converted to the smallest rational number given a relative_error.

Examples

>>> e = N(1) / 2
>>> print(e)
1/2
>>> print(N(1/3))
>>> print(N(0.33, 0.1))
>>> print(N('0.333`3'))
>>> print(N(Decimal('0.1234')))
3.3333333333333331e-1
1/3
3.33e-1
1.2340e-1