From 8e6e2ca534643fcde73fcd7e00f033db4d3e6a9b Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Sun, 9 Jun 2013 20:08:44 -0400 Subject: [PATCH] Fix the the bin() fix --- pyopencl/algorithm.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/pyopencl/algorithm.py b/pyopencl/algorithm.py index bedfb1a0..48cb2f04 100644 --- a/pyopencl/algorithm.py +++ b/pyopencl/algorithm.py @@ -249,13 +249,11 @@ def unique(ary, is_equal_expr="a == b", extra_args=[], preamble="", def to_bin(n): # Py 2.5 has no built-in bin() digs = [] - while True: + while n: digs.append(str(n % 2)) - n /= 2 - if not n: - break - digs.reverse() - return ''.join(digs) + n >>= 1 + + return ''.join(digs[::-1]) def _padded_bin(i, l): -- GitLab