In [1]:
from ahh import ext
import numpy as np

In [2]:
x = 3
ext.round_to(x, base=2) # round to nearest 2
x = 234
ext.round_to(x, base=5) # round to closest 5
x = 239
ext.round_to(x, base=5) # round to closest 5
x = 34
ext.round_to(x, base=10) # round to nearest 10
x = 9
ext.round_to(x, base=10) # round to nearest 10


Out[2]:
4
Out[2]:
235
Out[2]:
240
Out[2]:
30
Out[2]:
10

In [3]:
x = 12
oom = ext.get_order_mag(x) # order of magnitude
oom, np.power(10, oom)

x = 125
oom = ext.get_order_mag(x)
oom, np.power(10, oom)

x = 1
oom = ext.get_order_mag(x)
oom, np.power(10, oom)


Out[3]:
(1, 10)
Out[3]:
(2, 100)
Out[3]:
(0, 1)

In [ ]: