Skip to content

Commit d78e31a

Browse files
committed
fix PyLongNumBits node (int / long specializations)
1 parent 3e8c4dd commit d78e31a

File tree

1 file changed

+2
-2
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints

1 file changed

+2
-2
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntNodes.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,12 @@ public abstract static class PyLongNumBits extends Node {
8787

8888
@Specialization
8989
static int doInt(int value) {
90-
return Integer.bitCount(value);
90+
return Integer.SIZE - Integer.numberOfLeadingZeros(Math.abs(value));
9191
}
9292

9393
@Specialization
9494
static int doLong(long value) {
95-
return Long.bitCount(value);
95+
return Long.SIZE - Long.numberOfLeadingZeros(Math.abs(value));
9696
}
9797

9898
@Specialization

0 commit comments

Comments
 (0)