Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/mathlib.py
diff options
context:
space:
mode:
authorReinier Heeres <reinier@heeres.eu>2010-07-29 09:41:22 (GMT)
committer Reinier Heeres <reinier@heeres.eu>2010-07-29 09:41:22 (GMT)
commita4ee179c7088b79a31f366ee5c080bfb19abf39f (patch)
tree4496fd35d7a74df1f1d36964b367437ba2e9516b /mathlib.py
parent937be6a3a9e36876dce037dc72966097b7efa096 (diff)
Add function b10bin to support binary on python2.5
Diffstat (limited to 'mathlib.py')
-rw-r--r--mathlib.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/mathlib.py b/mathlib.py
index 9f7a301..3ef7751 100644
--- a/mathlib.py
+++ b/mathlib.py
@@ -32,15 +32,17 @@ from gettext import gettext as _
import locale
# Python 2.5 does not have a binary formatter built-in
+# This requires a function b10bin() to interpret the result
def format_bin(n):
- ret = '0b'
+ bits = ''
while n > 0:
if n & 1:
- ret += '1'
+ bits = '1' + bits
else:
- ret += '0'
+ bits = '0' + bits
n >>= 1
- return ret
+
+ return 'b10bin(%s)' % bits
try:
_BIN = bin