[pypy-commit] pypy jvm-improvements: Simpler implementations of float2longlong and longlong2float.

benol noreply at buildbot.pypy.org
Tue Jan 17 10:10:28 CET 2012


Author: Michal Bendowski <michal at bendowski.pl>
Branch: jvm-improvements
Changeset: r51381:79b211ffff3c
Date: 2012-01-16 21:19 +0100
http://bitbucket.org/pypy/pypy/changeset/79b211ffff3c/

Log:	Simpler implementations of float2longlong and longlong2float.

diff --git a/pypy/translator/jvm/src/pypy/PyPy.java b/pypy/translator/jvm/src/pypy/PyPy.java
--- a/pypy/translator/jvm/src/pypy/PyPy.java
+++ b/pypy/translator/jvm/src/pypy/PyPy.java
@@ -8,7 +8,6 @@
 import java.util.Map;
 import java.text.DecimalFormat;
 import java.lang.reflect.Array;
-import java.nio.ByteBuffer;
 
 /**
  * Class with a number of utility routines.  One instance of this is
@@ -285,17 +284,11 @@
     }
 
     public double pypy__longlong2float(long l) {
-        ByteBuffer buf = ByteBuffer.allocate(8);
-        buf.putLong(l);
-        buf.flip();
-        return buf.getDouble();
+        return Double.longBitsToDouble(l);
     }
 
     public long pypy__float2longlong(double d) {
-        ByteBuffer buf = ByteBuffer.allocate(8);
-        buf.putDouble(d);
-        buf.flip();
-        return buf.getLong();
+        return Double.doubleToRawLongBits(d);
     }
 
     public double ooparse_float(String s) {


More information about the pypy-commit mailing list