Skip to content

Instantly share code, notes, and snippets.

@jyukutyo
Created August 31, 2019 22:08
Show Gist options
  • Save jyukutyo/8960bd23d6868f7f835458a54507de87 to your computer and use it in GitHub Desktop.
Save jyukutyo/8960bd23d6868f7f835458a54507de87 to your computer and use it in GitHub Desktop.
Bytecode representation of numerical values
public class Temp {
public static void main(String[] args) {
System.out.println(1);
System.out.println(127);
System.out.println(1000);
System.out.println(10000000);
System.out.println(100000000000000000l);
System.out.println(100000000000000000d);
}
}
/*
javap -c Temp
public class Temp {
public Temp();
Code:
0: aload_0
1: invokespecial #1 // Method java/lang/Object."<init>":()V
4: return
public static void main(java.lang.String[]);
Code:
0: getstatic #7 // Field java/lang/System.out:Ljava/io/PrintStream;
3: iconst_1
4: invokevirtual #13 // Method java/io/PrintStream.println:(I)V
7: getstatic #7 // Field java/lang/System.out:Ljava/io/PrintStream;
10: bipush 127
12: invokevirtual #13 // Method java/io/PrintStream.println:(I)V
15: getstatic #7 // Field java/lang/System.out:Ljava/io/PrintStream;
18: sipush 1000
21: invokevirtual #13 // Method java/io/PrintStream.println:(I)V
24: getstatic #7 // Field java/lang/System.out:Ljava/io/PrintStream;
27: ldc #19 // int 10000000
29: invokevirtual #13 // Method java/io/PrintStream.println:(I)V
32: getstatic #7 // Field java/lang/System.out:Ljava/io/PrintStream;
35: ldc2_w #20 // long 100000000000000000l
38: invokevirtual #22 // Method java/io/PrintStream.println:(J)V
41: getstatic #7 // Field java/lang/System.out:Ljava/io/PrintStream;
44: ldc2_w #25 // double 1.0E17d
47: invokevirtual #27 // Method java/io/PrintStream.println:(D)V
50: return
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment