Merge of new advances in arithmetic including JavaScript Number having all methods of java.lang.Number and good valueOf implementation
authorJaroslav Tulach <jaroslav.tulach@apidesign.org>
Thu, 28 Feb 2013 09:50:14 +0100
changeset 790da63749558e2
parent 789 bb7506513353
parent 783 8264f07b1f46
child 791 af4001c85438
Merge of new advances in arithmetic including JavaScript Number having all methods of java.lang.Number and good valueOf implementation
rt/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java
rt/vm/src/test/java/org/apidesign/vm4brwsr/NumberTest.java
     1.1 --- a/rt/emul/mini/src/main/java/java/io/DataInputStream.java	Thu Feb 28 07:48:54 2013 +0100
     1.2 +++ b/rt/emul/mini/src/main/java/java/io/DataInputStream.java	Thu Feb 28 09:50:14 2013 +0100
     1.3 @@ -468,42 +468,8 @@
     1.4       * @see        java.lang.Double#longBitsToDouble(long)
     1.5       */
     1.6      public final double readDouble() throws IOException {
     1.7 -        int hi = readInt();
     1.8 -        int low = readInt();
     1.9 -        return toDouble(hi, low);
    1.10 -    }
    1.11 -    
    1.12 -    @JavaScriptBody(args={ "hi", "low" },
    1.13 -        body=
    1.14 -          "if (low == 0) {\n"
    1.15 -        + "  if (hi === 0x7ff00000) return Number.POSITIVE_INFINITY;\n"
    1.16 -        + "  if (hi === 0xfff00000) return Number.NEGATIVE_INFINITY;\n"
    1.17 -        + "}\n"
    1.18 -        + "if (hi >= 0x7ff00000 && hi <= 0x7fffffff) return Number.NaN;\n"
    1.19 -        + "if (hi >= 0xfff00000 && hi <= 0xffffffff) return Number.NaN;\n"
    1.20 -        + "var s = (hi & 0x80000000) === 0 ? 1 : -1;\n"
    1.21 -        + "var e = (hi >> 20) & 0x7ff;\n"
    1.22 -        + "var to32 = low >> 0;\n"
    1.23 -        + "if (e === 0) {\n"
    1.24 -        + "  if (to32 & 0x80000000) {\n"
    1.25 -        + "    hi = hi << 1 + 1; low = low << 1;\n"
    1.26 -        + "  } else {\n"
    1.27 -        + "    hi = hi << 1; low = low << 1;\n"
    1.28 -        + "  }\n" 
    1.29 -        + "} else {\n"
    1.30 -        + "    hi = (hi & 0xfffff) | 0x100000;\n"
    1.31 -        + "}\n"
    1.32 -        + "to32 = low >> 0;\n"
    1.33 -        + "var m = Math.pow(2.0, 32) * hi + to32;\n"
    1.34 -        + "var r = s * m * Math.pow(2.0, e - 1075);\n"
    1.35 -        + "//throw 'exp: ' + e + ' sign: ' + s + ' hi:' + hi + ' low: ' + low + ' m: ' + m + ' r: ' + r;\n"
    1.36 -        + "return r;\n"
    1.37 -    )
    1.38 -    private static double toDouble(int hi, int low) {
    1.39 -        long both = hi;
    1.40 -        both = (both << 32) & low;
    1.41 -        return Double.doubleToLongBits(both);
    1.42 -    }
    1.43 +        return Double.longBitsToDouble(readLong());
    1.44 +    }    
    1.45  
    1.46      private char lineBuffer[];
    1.47  
     2.1 --- a/rt/emul/mini/src/main/java/java/lang/Double.java	Thu Feb 28 07:48:54 2013 +0100
     2.2 +++ b/rt/emul/mini/src/main/java/java/lang/Double.java	Thu Feb 28 09:50:14 2013 +0100
     2.3 @@ -920,6 +920,26 @@
     2.4       * @return  the {@code double} floating-point value with the same
     2.5       *          bit pattern.
     2.6       */
     2.7 +    @JavaScriptBody(args={ "bits" },
     2.8 +        body=
     2.9 +          "var hi = bits.high32();\n"
    2.10 +        + "var s = (hi & 0x80000000) === 0 ? 1 : -1;\n"
    2.11 +        + "var e = (hi >> 20) & 0x7ff;\n"
    2.12 +        + "if (e === 0x7ff) {\n"
    2.13 +        + "  if ((bits == 0) && ((hi & 0xfffff) === 0)) {\n"
    2.14 +        + "    return (s > 0) ? Number.POSITIVE_INFINITY"
    2.15 +                          + " : Number.NEGATIVE_INFINITY;\n"
    2.16 +        + "  }\n"
    2.17 +        + "  return Number.NaN;\n"
    2.18 +        + "}\n"
    2.19 +        + "var m = (hi & 0xfffff).next32(bits);\n"
    2.20 +        + "if (e === 0) {\n"
    2.21 +        + "  m = m.shl64(1);\n"
    2.22 +        + "} else {\n"
    2.23 +        + "  m.hi = m.high32() | 0x100000;\n"
    2.24 +        + "}\n"
    2.25 +        + "return s * m.toFP() * Math.pow(2.0, e - 1075);\n"
    2.26 +    )
    2.27      public static native double longBitsToDouble(long bits);
    2.28  
    2.29      /**
     3.1 --- a/rt/emul/mini/src/main/java/java/lang/Float.java	Thu Feb 28 07:48:54 2013 +0100
     3.2 +++ b/rt/emul/mini/src/main/java/java/lang/Float.java	Thu Feb 28 09:50:14 2013 +0100
     3.3 @@ -822,13 +822,13 @@
     3.4            "var s = ((bits >> 31) == 0) ? 1 : -1;\n"
     3.5          + "var e = ((bits >> 23) & 0xff);\n"
     3.6          + "if (e === 0xff) {\n"
     3.7 -        + "    if ((bits & 0x7fffff) === 0) {\n"
     3.8 -        + "        return (s > 0) ? Number.POSITIVE_INFINITY"
     3.9 -                              + " : Number.NEGATIVE_INFINITY;\n"
    3.10 -        + "    }\n"
    3.11 -        + "    return Number.NaN;\n"
    3.12 +        + "  if ((bits & 0x7fffff) === 0) {\n"
    3.13 +        + "    return (s > 0) ? Number.POSITIVE_INFINITY"
    3.14 +                          + " : Number.NEGATIVE_INFINITY;\n"
    3.15 +        + "  }\n"
    3.16 +        + "  return Number.NaN;\n"
    3.17          + "}\n"
    3.18 -        + "var m = (e == 0) ?\n"
    3.19 +        + "var m = (e === 0) ?\n"
    3.20          + "  (bits & 0x7fffff) << 1 :\n"
    3.21          + "  (bits & 0x7fffff) | 0x800000;\n"
    3.22          + "return s * m * Math.pow(2.0, e - 150);\n"
     4.1 --- a/rt/emul/mini/src/main/java/java/lang/Number.java	Thu Feb 28 07:48:54 2013 +0100
     4.2 +++ b/rt/emul/mini/src/main/java/java/lang/Number.java	Thu Feb 28 09:50:14 2013 +0100
     4.3 @@ -26,6 +26,9 @@
     4.4  package java.lang;
     4.5  
     4.6  import org.apidesign.bck2brwsr.core.ExtraJavaScript;
     4.7 +import org.apidesign.bck2brwsr.core.JavaScriptBody;
     4.8 +import org.apidesign.bck2brwsr.core.JavaScriptOnly;
     4.9 +import org.apidesign.bck2brwsr.core.JavaScriptPrototype;
    4.10  
    4.11  /**
    4.12   * The abstract class <code>Number</code> is the superclass of classes
    4.13 @@ -52,6 +55,7 @@
    4.14      resource="/org/apidesign/vm4brwsr/emul/lang/java_lang_Number.js",
    4.15      processByteCode=true
    4.16  )
    4.17 +@JavaScriptPrototype(container = "Number.prototype", prototype = "new Number")
    4.18  public abstract class Number implements java.io.Serializable {
    4.19      /**
    4.20       * Returns the value of the specified number as an <code>int</code>.
    4.21 @@ -60,6 +64,7 @@
    4.22       * @return  the numeric value represented by this object after conversion
    4.23       *          to type <code>int</code>.
    4.24       */
    4.25 +    @JavaScriptBody(args = {}, body = "return this | 0;")
    4.26      public abstract int intValue();
    4.27  
    4.28      /**
    4.29 @@ -69,6 +74,7 @@
    4.30       * @return  the numeric value represented by this object after conversion
    4.31       *          to type <code>long</code>.
    4.32       */
    4.33 +    @JavaScriptBody(args = {}, body = "return this.toLong();")
    4.34      public abstract long longValue();
    4.35  
    4.36      /**
    4.37 @@ -78,6 +84,7 @@
    4.38       * @return  the numeric value represented by this object after conversion
    4.39       *          to type <code>float</code>.
    4.40       */
    4.41 +    @JavaScriptBody(args = {}, body = "return this;")
    4.42      public abstract float floatValue();
    4.43  
    4.44      /**
    4.45 @@ -87,6 +94,7 @@
    4.46       * @return  the numeric value represented by this object after conversion
    4.47       *          to type <code>double</code>.
    4.48       */
    4.49 +    @JavaScriptBody(args = {}, body = "return this;")
    4.50      public abstract double doubleValue();
    4.51  
    4.52      /**
    4.53 @@ -115,4 +123,15 @@
    4.54  
    4.55      /** use serialVersionUID from JDK 1.0.2 for interoperability */
    4.56      private static final long serialVersionUID = -8742448824652078965L;
    4.57 +    
    4.58 +    static {
    4.59 +        // as last step of initialization, initialize valueOf method
    4.60 +        initValueOf();
    4.61 +    }
    4.62 +    @JavaScriptBody(args = {  }, body = 
    4.63 +        "var p = vm.java_lang_Number(false);\n" +
    4.64 +        "p.valueOf = function() { return this.doubleValue__D(); };\n" +
    4.65 +        "p.toString = function() { return this.toString__Ljava_lang_String_2(); };"
    4.66 +    )
    4.67 +    private native static void initValueOf();
    4.68  }
     5.1 --- a/rt/emul/mini/src/main/resources/org/apidesign/vm4brwsr/emul/lang/java_lang_Number.js	Thu Feb 28 07:48:54 2013 +0100
     5.2 +++ b/rt/emul/mini/src/main/resources/org/apidesign/vm4brwsr/emul/lang/java_lang_Number.js	Thu Feb 28 09:50:14 2013 +0100
     5.3 @@ -28,8 +28,17 @@
     5.4      return this.hi ? this.hi * (__m32+1) + this : this;
     5.5  };
     5.6  Number.prototype.toLong = function() {
     5.7 -    var hi = (this > __m32) ? (Math.floor(this / (__m32+1))) | 0 : 0;
     5.8 -    return hi.next32(Math.floor(this % (__m32+1)));
     5.9 +    var hi = (this / (__m32+1)) | 0;
    5.10 +    var low = (this % (__m32+1)) | 0;
    5.11 +    if (low < 0) {
    5.12 +        low += __m32+1;
    5.13 +    }
    5.14 +        
    5.15 +    if (this < 0) {
    5.16 +        hi -= 1;
    5.17 +    }
    5.18 +
    5.19 +    return hi.next32(low);
    5.20  };
    5.21  
    5.22  Number.prototype.toExactString = function() {
    5.23 @@ -481,7 +490,7 @@
    5.24              v = x;
    5.25          }
    5.26  
    5.27 -        if ((v === 0) && (v.high32() === 0)) {
    5.28 +        if ((v == 0) && (v.high32() === 0)) {
    5.29              __handleDivByZero();
    5.30          }
    5.31  
    5.32 @@ -522,7 +531,7 @@
    5.33              v = x;
    5.34          }
    5.35  
    5.36 -        if ((v === 0) && (v.high32() === 0)) {
    5.37 +        if ((v == 0) && (v.high32() === 0)) {
    5.38              __handleDivByZero();
    5.39          }
    5.40  
     6.1 --- a/rt/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java	Thu Feb 28 07:48:54 2013 +0100
     6.2 +++ b/rt/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java	Thu Feb 28 09:50:14 2013 +0100
     6.3 @@ -695,19 +695,19 @@
     6.4                      emit(out, "var @2 = @1;", smapper.popD(), smapper.pushF());
     6.5                      break;
     6.6                  case opc_f2i:
     6.7 -                    emit(out, "var @2 = Math.floor(@1).toInt32();",
     6.8 +                    emit(out, "var @2 = @1.toInt32();",
     6.9                           smapper.popF(), smapper.pushI());
    6.10                      break;
    6.11                  case opc_f2l:
    6.12 -                    emit(out, "var @2 = Math.floor(@1).toLong();",
    6.13 +                    emit(out, "var @2 = @1.toLong();",
    6.14                           smapper.popF(), smapper.pushL());
    6.15                      break;
    6.16                  case opc_d2i:
    6.17 -                    emit(out, "var @2 = Math.floor(@1).toInt32();",
    6.18 +                    emit(out, "var @2 = @1.toInt32();",
    6.19                           smapper.popD(), smapper.pushI());
    6.20                      break;
    6.21                  case opc_d2l:
    6.22 -                    emit(out, "var @2 = Math.floor(@1).toLong();",
    6.23 +                    emit(out, "var @2 = @1.toLong();",
    6.24                           smapper.popD(), smapper.pushL());
    6.25                      break;
    6.26                  case opc_i2b:
     7.1 --- a/rt/vm/src/test/java/org/apidesign/vm4brwsr/NumberTest.java	Thu Feb 28 07:48:54 2013 +0100
     7.2 +++ b/rt/vm/src/test/java/org/apidesign/vm4brwsr/NumberTest.java	Thu Feb 28 09:50:14 2013 +0100
     7.3 @@ -143,6 +143,49 @@
     7.4          );
     7.5      }
     7.6  
     7.7 +    @Test public void everyNumberHasJavaLangNumberMethods() throws Exception {
     7.8 +        assertExec("Can we call doubleValue?", 
     7.9 +            Numbers.class, "seven__DI", 
    7.10 +            Double.valueOf(7.0), 0
    7.11 +        );
    7.12 +    }
    7.13 +    @Test public void everyNumberHasJavaLangNumberMethodsInt() throws Exception {
    7.14 +        assertExec("Can we call doubleValue?", 
    7.15 +            Numbers.class, "seven__DI", 
    7.16 +            Double.valueOf(7.0), 1
    7.17 +        );
    7.18 +    }
    7.19 +    @Test public void everyNumberHasJavaLangNumberMethodsLong() throws Exception {
    7.20 +        assertExec("Can we call doubleValue?", 
    7.21 +            Numbers.class, "seven__DI", 
    7.22 +            Double.valueOf(7.0), 2
    7.23 +        );
    7.24 +    }
    7.25 +    @Test public void everyNumberHasJavaLangNumberMethodsShort() throws Exception {
    7.26 +        assertExec("Can we call doubleValue?", 
    7.27 +            Numbers.class, "seven__DI", 
    7.28 +            Double.valueOf(7.0), 3
    7.29 +        );
    7.30 +    }
    7.31 +    @Test public void everyNumberHasJavaLangNumberMethodsByte() throws Exception {
    7.32 +        assertExec("Can we call doubleValue?", 
    7.33 +            Numbers.class, "seven__DI", 
    7.34 +            Double.valueOf(7.0), 4
    7.35 +        );
    7.36 +    }
    7.37 +    @Test public void valueOfNumber() throws Exception {
    7.38 +        assertExec("Can we call JavaScripts valueOf?", 
    7.39 +            Numbers.class, "seven__DI", 
    7.40 +            Double.valueOf(7.0), 8
    7.41 +        );
    7.42 +    }
    7.43 +    @Test public void valueOfLongNumber() throws Exception {
    7.44 +        assertExec("Can we call JavaScripts valueOf?", 
    7.45 +            Numbers.class, "seven__DI", 
    7.46 +            Double.valueOf(Long.MAX_VALUE / 5), 9
    7.47 +        );
    7.48 +    }
    7.49 +
    7.50      private static TestVM code;
    7.51  
    7.52      @BeforeClass
     8.1 --- a/rt/vm/src/test/java/org/apidesign/vm4brwsr/Numbers.java	Thu Feb 28 07:48:54 2013 +0100
     8.2 +++ b/rt/vm/src/test/java/org/apidesign/vm4brwsr/Numbers.java	Thu Feb 28 09:50:14 2013 +0100
     8.3 @@ -20,6 +20,7 @@
     8.4  import java.io.ByteArrayInputStream;
     8.5  import java.io.DataInputStream;
     8.6  import java.io.IOException;
     8.7 +import org.apidesign.bck2brwsr.core.JavaScriptBody;
     8.8  
     8.9  /**
    8.10   *
    8.11 @@ -67,4 +68,23 @@
    8.12      static String floatToString() {
    8.13          return new Float(7.0).toString().toString();
    8.14      }
    8.15 +    
    8.16 +    static double seven(int todo) {
    8.17 +        switch (todo) {
    8.18 +            case 0: return sevenNew().doubleValue();
    8.19 +            case 1: return sevenNew().intValue();
    8.20 +            case 2: return sevenNew().longValue();
    8.21 +            case 3: return sevenNew().shortValue();
    8.22 +            case 4: return sevenNew().byteValue();
    8.23 +            case 8: return valueOf(Double.valueOf(7.0));
    8.24 +            case 9: return valueOf(Long.valueOf(Long.MAX_VALUE / 5));
    8.25 +            default: throw new IllegalStateException();
    8.26 +        }
    8.27 +    }
    8.28 +    
    8.29 +    @JavaScriptBody(args = {}, body = "return 7;")
    8.30 +    private static native Number sevenNew();
    8.31 +    
    8.32 +    @JavaScriptBody(args = { "o" }, body = "return o.valueOf();")
    8.33 +    private static native double valueOf(Object o);
    8.34  }
     9.1 --- a/rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/IntegerArithmeticTest.java	Thu Feb 28 07:48:54 2013 +0100
     9.2 +++ b/rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/IntegerArithmeticTest.java	Thu Feb 28 09:50:14 2013 +0100
     9.3 @@ -50,6 +50,14 @@
     9.4      private static int neg(int x) {
     9.5          return (-x);
     9.6      }
     9.7 +
     9.8 +    private static float fadd(float x, float y) {
     9.9 +        return x + y;
    9.10 +    }
    9.11 +
    9.12 +    private static double dadd(double x, double y) {
    9.13 +        return x + y;
    9.14 +    }
    9.15      
    9.16      @Compare public int addOverflow() {
    9.17          return add(Integer.MAX_VALUE, 1);
    9.18 @@ -90,7 +98,7 @@
    9.19      @Compare public int division() {
    9.20          return div(1, 2);
    9.21      }
    9.22 -    
    9.23 +
    9.24      @Compare public int divisionReminder() {
    9.25          return mod(1, 2);
    9.26      }
    9.27 @@ -103,6 +111,14 @@
    9.28          return mod(-7, 3);
    9.29      }
    9.30  
    9.31 +    @Compare public int conversionFromFloat() {
    9.32 +        return (int) fadd(-2, -0.6f);
    9.33 +    }
    9.34 +
    9.35 +    @Compare public int conversionFromDouble() {
    9.36 +        return (int) dadd(-2, -0.6);
    9.37 +    }
    9.38 +
    9.39      @Compare public boolean divByZeroThrowsArithmeticException() {
    9.40          try {
    9.41              div(1, 0);
    10.1 --- a/rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/LongArithmeticTest.java	Thu Feb 28 07:48:54 2013 +0100
    10.2 +++ b/rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/LongArithmeticTest.java	Thu Feb 28 09:50:14 2013 +0100
    10.3 @@ -26,55 +26,63 @@
    10.4   * @author Jaroslav Tulach <jtulach@netbeans.org>
    10.5   */
    10.6  public class LongArithmeticTest {
    10.7 -    
    10.8 +
    10.9      private static long add(long x, long y) {
   10.10          return (x + y);
   10.11      }
   10.12 -    
   10.13 +
   10.14      private static long sub(long x, long y) {
   10.15          return (x - y);
   10.16      }
   10.17 -    
   10.18 +
   10.19      private static long mul(long x, long y) {
   10.20          return (x * y);
   10.21      }
   10.22 -    
   10.23 +
   10.24      private static long div(long x, long y) {
   10.25          return (x / y);
   10.26      }
   10.27 -    
   10.28 +
   10.29      private static long mod(long x, long y) {
   10.30          return (x % y);
   10.31      }
   10.32 -    
   10.33 +
   10.34      private static long neg(long x) {
   10.35          return (-x);
   10.36      }
   10.37 -    
   10.38 +
   10.39      private static long shl(long x, int b) {
   10.40          return (x << b);
   10.41      }
   10.42 -    
   10.43 +
   10.44      private static long shr(long x, int b) {
   10.45          return (x >> b);
   10.46      }
   10.47 -    
   10.48 +
   10.49      private static long ushr(long x, int b) {
   10.50          return (x >>> b);
   10.51      }
   10.52 -    
   10.53 +
   10.54      private static long and(long x, long y) {
   10.55          return (x & y);
   10.56      }
   10.57 -    
   10.58 +
   10.59      private static long or(long x, long y) {
   10.60          return (x | y);
   10.61      }
   10.62 -    
   10.63 +
   10.64      private static long xor(long x, long y) {
   10.65          return (x ^ y);
   10.66      }
   10.67 -    
   10.68 +
   10.69 +    private static float fadd(float x, float y) {
   10.70 +        return x + y;
   10.71 +    }
   10.72 +
   10.73 +    private static double dadd(double x, double y) {
   10.74 +        return x + y;
   10.75 +    }
   10.76 +
   10.77      public static int compare(long x, long y, int zero) {
   10.78          final int xyResult = compareL(x, y, zero);
   10.79          final int yxResult = compareL(y, x, zero);
   10.80 @@ -106,15 +114,15 @@
   10.81  
   10.82          return (trueCount == 1) ? result : -2;
   10.83      }
   10.84 -    
   10.85 +
   10.86      @Compare public long conversion() {
   10.87          return Long.MAX_VALUE;
   10.88      }
   10.89 -    
   10.90 +
   10.91      @Compare public long negate1() {
   10.92          return neg(0x00fa37d7763e0ca1l);
   10.93      }
   10.94 -    
   10.95 +
   10.96      @Compare public long negate2() {
   10.97          return neg(0x80fa37d7763e0ca1l);
   10.98      }
   10.99 @@ -134,11 +142,11 @@
  10.100      @Compare public long addMaxLongAndMaxLong() {
  10.101          return add(Long.MAX_VALUE, Long.MAX_VALUE);
  10.102      }
  10.103 -    
  10.104 +
  10.105      @Compare public long subMinLongAndMinLong() {
  10.106          return sub(Long.MIN_VALUE, Long.MIN_VALUE);
  10.107      }
  10.108 -    
  10.109 +
  10.110      @Compare public long subMinLongAndMaxLong() {
  10.111          return sub(Long.MIN_VALUE, Long.MAX_VALUE);
  10.112      }
  10.113 @@ -146,23 +154,23 @@
  10.114      @Compare public long multiplyMaxLong() {
  10.115          return mul(Long.MAX_VALUE, 2l);
  10.116      }
  10.117 -    
  10.118 +
  10.119      @Compare public long multiplyMaxLongAndMaxLong() {
  10.120          return mul(Long.MAX_VALUE, Long.MAX_VALUE);
  10.121      }
  10.122 -    
  10.123 +
  10.124      @Compare public long multiplyMinLong() {
  10.125          return mul(Long.MIN_VALUE, 2l);
  10.126      }
  10.127 -    
  10.128 +
  10.129      @Compare public long multiplyMinLongAndMinLong() {
  10.130          return mul(Long.MIN_VALUE, Long.MIN_VALUE);
  10.131      }
  10.132 -    
  10.133 +
  10.134      @Compare public long multiplyPrecision() {
  10.135          return mul(0x00fa37d7763e0ca1l, 0xa7b3432fff00123el);
  10.136      }
  10.137 -    
  10.138 +
  10.139      @Compare public long divideSmallPositiveNumbers() {
  10.140          return div(0xabcdef, 0x123);
  10.141      }
  10.142 @@ -251,6 +259,22 @@
  10.143          return mod(0x7fff800000000000l, 0x800000000001l);
  10.144      }
  10.145  
  10.146 +    @Compare public long conversionFromFloatPositive() {
  10.147 +        return (long) fadd(2, 0.6f);
  10.148 +    }
  10.149 +
  10.150 +    @Compare public long conversionFromFloatNegative() {
  10.151 +        return (long) fadd(-2, -0.6f);
  10.152 +    }
  10.153 +
  10.154 +    @Compare public long conversionFromDoublePositive() {
  10.155 +        return (long) dadd(0x20ffff0000L, 0.6);
  10.156 +    }
  10.157 +
  10.158 +    @Compare public long conversionFromDoubleNegative() {
  10.159 +        return (long) dadd(-0x20ffff0000L, -0.6);
  10.160 +    }
  10.161 +
  10.162      @Compare public boolean divByZeroThrowsArithmeticException() {
  10.163          try {
  10.164              div(1, 0);
  10.165 @@ -272,63 +296,63 @@
  10.166      @Compare public long shiftL1() {
  10.167          return shl(0x00fa37d7763e0ca1l, 5);
  10.168      }
  10.169 -    
  10.170 +
  10.171      @Compare public long shiftL2() {
  10.172          return shl(0x00fa37d7763e0ca1l, 32);
  10.173      }
  10.174 -    
  10.175 +
  10.176      @Compare public long shiftL3() {
  10.177          return shl(0x00fa37d7763e0ca1l, 45);
  10.178      }
  10.179 -    
  10.180 +
  10.181      @Compare public long shiftR1() {
  10.182          return shr(0x00fa37d7763e0ca1l, 5);
  10.183      }
  10.184 -    
  10.185 +
  10.186      @Compare public long shiftR2() {
  10.187          return shr(0x00fa37d7763e0ca1l, 32);
  10.188      }
  10.189 -    
  10.190 +
  10.191      @Compare public long shiftR3() {
  10.192          return shr(0x00fa37d7763e0ca1l, 45);
  10.193      }
  10.194 -    
  10.195 +
  10.196      @Compare public long uShiftR1() {
  10.197          return ushr(0x00fa37d7763e0ca1l, 5);
  10.198      }
  10.199 -    
  10.200 +
  10.201      @Compare public long uShiftR2() {
  10.202          return ushr(0x00fa37d7763e0ca1l, 45);
  10.203      }
  10.204 -    
  10.205 +
  10.206      @Compare public long uShiftR3() {
  10.207          return ushr(0xf0fa37d7763e0ca1l, 5);
  10.208      }
  10.209 -    
  10.210 +
  10.211      @Compare public long uShiftR4() {
  10.212          return ushr(0xf0fa37d7763e0ca1l, 45);
  10.213      }
  10.214 -    
  10.215 +
  10.216      @Compare public long and1() {
  10.217          return and(0x00fa37d7763e0ca1l, 0xa7b3432fff00123el);
  10.218      }
  10.219 -    
  10.220 +
  10.221      @Compare public long or1() {
  10.222          return or(0x00fa37d7763e0ca1l, 0xa7b3432fff00123el);
  10.223      }
  10.224 -    
  10.225 +
  10.226      @Compare public long xor1() {
  10.227          return xor(0x00fa37d7763e0ca1l, 0xa7b3432fff00123el);
  10.228      }
  10.229 -    
  10.230 +
  10.231      @Compare public long xor2() {
  10.232          return xor(0x00fa37d7763e0ca1l, 0x00000000ff00123el);
  10.233      }
  10.234 -    
  10.235 +
  10.236      @Compare public long xor3() {
  10.237          return xor(0x00000000763e0ca1l, 0x00000000ff00123el);
  10.238      }
  10.239 -    
  10.240 +
  10.241      @Compare public int compareSameNumbers() {
  10.242          return compare(0x0000000000000000l, 0x0000000000000000l, 0);
  10.243      }