View Javadoc
1   package com.puppycrawl.tools.checkstyle.grammars;
2   
3   /**
4    * Input for Java 7 numerical literals.
5    */
6   public class InputJava7NumericalLiterals
7   {
8       int i1 = 0b00011110;
9       int i2 = 0B00011110;
10      int i3 = 0xA;
11      int i4 = 0x1___A_F;
12      int i5 = 0b1;
13      int i6 = 0b1___1_0;
14      int i7 = 0;
15      int i8 = 02;
16      int i9 = 0_123;
17      int i10 = 1;
18      int i11 = 1___3;
19      int i12 = 1_43_43598_7;
20      
21      long l1 = 0b00011110L;
22      long l2 = 0B00011110l;
23      long l3 = 0xAL;
24      long l4 = 0x1___A_FL;
25      long l5 = 0b1L;
26      long l6 = 0b1___1_0L;
27      long l7 = 0l;
28      long l8 = 02L;
29      long l9 = 0_123l;
30      long l10 = 1l;
31      long l11 = 1___3l;
32      long l12 = 1_43_43598_7L;
33      long l13 = 1_43_43598_7; // int promoted to long
34      
35      // the grammar considers floating point values to be of type "float" by default which is wrong, it should be "double".
36      
37      float f1 = .1f;
38      float f2 = (float) 1.; // double "downgraded" to float
39      float f3 = 0f;
40      float f4 = (float) 1e0; // double "downgraded" to float
41      float f5 = 1e0f;
42      float f6 = 12.345F;
43      float f7 = (float) .5____2_1; // double "downgraded" to float
44      float f8 = (float) 1__42__3.; // double "downgraded" to float
45      float f9 = 0__2_4__324f;
46      float f10 = (float) 1_34e0; // double "downgraded" to float
47      float f11 = 1__1_2e0f;
48      float f12 = 2_1___2.3__4_5F;
49      float f13 = (float) 1_34e0__4__3; // double "downgraded" to float
50      float f14 = 1__1_2e00__000_4f;
51      float f15 = 2_1___2.3__4_5e00______0_5F;
52      
53      double d1 = .1d;
54      double d2 = 1.D;
55      double d3 = 0d;
56      double d4 = 1e0D;
57      double d5 = 1e0d;
58      double d6 = 12.345D;
59      double d7 = .5____2_1d;
60      double d8 = 1__42__3.D;
61      double d9 = 0__2_4__324d;
62      double d10 = 1_34e0d;
63      double d11 = 1__1_2e0d;
64      double d12 = 2_1___2.3__4_5D;
65      double d13 = 1_34e0__4__3d;
66      double d14 = 1__1_2e00__000_4d;
67      double d15 = 2_1___2.3__4_5e00______0_5D;
68      double d16 = 0.12___34; // "float" promoted to double
69      
70      float hf1 = (float) 0x.1___AFp1; // double "downgraded" to float
71      float hf2 = 0x.1___AFp0__0__0f;
72      float hf3 = 0x2__3_34.4___AFP00_00f;
73      
74      double hd1 = 0x.1___AFp1;
75      double hd2 = 0x.1___AFp0__0__0d;
76      double hd3 = 0x2__3_34.4___AFP00_00d;
77      
78      int doc1 = 1234_5678;
79      long doc2 = 1_2_3_4__5_6_7_8L;
80      int doc3 = 0b0001_0010_0100_1000;
81      double doc4 = 3.141_592_653_589_793d;
82      double doc5 = 0x1.ffff_ffff_ffff_fP1_023; // Double.MAX_VALUE
83  
84  }