2 * Ensure that Double and Float compile time constants are correctly
5 * @author: Edouard G. Parmelan <egp@free.fr> */
6 public class DoubleConst
8 static void test (String title, float value, int expect)
10 int got = Float.floatToIntBits (value);
13 System.out.println (title
14 + " expect " + Integer.toString (expect, 16)
15 + " got " + Integer.toString (got, 16)
20 static void test (String title, double value, long expect)
22 long got = Double.doubleToLongBits (value);
25 System.out.println (title
26 + " expect " + Long.toString (expect, 16)
27 + " got " + Long.toString (got, 16)
32 public static void main (String args[])
34 System.out.println("Float tests:");
35 test ("POSITIVE_INTINITY", Float.POSITIVE_INFINITY, 0x7f800000);
36 test ("NEGATIVE_INTINITY", Float.NEGATIVE_INFINITY, 0xff800000);
37 test ("NaN", Float.NaN, 0x7fc00000);
38 test ("MIN_VALUE", Float.MIN_VALUE, 0x00000001);
39 test ("MAX_VALUE", Float.MAX_VALUE, 0x7f7fffff);
41 System.out.println("Double tests:");
42 test ("POSITIVE_INTINITY", Double.POSITIVE_INFINITY, 0x7ff0000000000000L);
43 test ("NEGATIVE_INTINITY", Double.NEGATIVE_INFINITY, 0xfff0000000000000L);
44 test ("NaN", Double.NaN, 0x7ff8000000000000L);
45 test ("MIN_VALUE", Double.MIN_VALUE, 0x0000000000000001L);
46 test ("MAX_VALUE", Double.MAX_VALUE, 0x7fefffffffffffffL);