Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/functions.py
diff options
context:
space:
mode:
Diffstat (limited to 'functions.py')
-rw-r--r--functions.py19
1 files changed, 6 insertions, 13 deletions
diff --git a/functions.py b/functions.py
index 8a737ff..daaac81 100644
--- a/functions.py
+++ b/functions.py
@@ -160,19 +160,12 @@ atanh.__doc__ = _(
which the hyperbolic tangent equals x.')
def b10bin(x):
- ret = 0
- while x > 0:
- ret <<= 1
+ try:
+ result = int(str(x), 2)
+ except ValueError:
+ raise ValueError(_('Number does not look binary in base 10'))
- y = x % 10
- if y == 1:
- ret += 1
- elif y != 0:
- raise ValueError(_('Number does not look binary in base 10'))
-
- x /= 10
-
- return ret
+ return result
b10bin.__doc__ = _(
'b10bin(x), interpret a number written in base 10 as binary, e.g.: \
@@ -313,7 +306,7 @@ exponent exp() equals x. Defined for x >= 0.')
def log10(x):
if float(x) > 0:
- return math.log(float(x))
+ return math.log10(float(x))
else:
raise ValueError(_('Logarithm(x) only defined for x > 0'))
log10.__doc__ = _(