MCPcopy Create free account
hub / github.com/andreabergia/rjvm / NumericTypes

Class NumericTypes

vm/tests/resources/rjvm/NumericTypes.java:3–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1package rjvm;
2
3public class NumericTypes {
4 public static void main(String[] args) {
5 shortAndCharMath((short) 1, (char) 2);
6 floatAndIntMath(1, 2.45f);
7 longMath(1, 3);
8 doubleMath(1, 3.45);
9 negate(returnOneInt(), returnOneLong(), returnOneFloat(), returnOneDouble());
10 logicalShifts(4, 4);
11 }
12
13 private static void shortAndCharMath(short s, char c) {
14 tempPrint(((short) (s + c)));
15 }
16
17 private static void floatAndIntMath(int i, float f) {
18 tempPrint(i + f);
19 tempPrint((int) (i + f));
20 tempPrint((long) (i + f));
21 tempPrint((double) (i + f));
22 }
23
24 private static void longMath(int i, long l) {
25 tempPrint(l - i);
26 tempPrint((int) (l - i));
27 tempPrint((float) (l - i));
28 tempPrint((double) (l - i));
29 }
30
31 private static void doubleMath(int i, double d) {
32 tempPrint(i + d);
33 tempPrint((int) (i + d));
34 tempPrint((float) (i + d));
35 tempPrint((long) (i + d));
36 }
37
38 private static void negate(int i, long l, float f, double d) {
39 tempPrint(-i);
40 tempPrint(-l);
41 tempPrint(-f);
42 tempPrint(-d);
43 }
44
45 private static void logicalShifts(int i, long l) {
46 tempPrint(i >> 2);
47 tempPrint((-i) >>> 2);
48 tempPrint(i << 1);
49
50 tempPrint(l >> 2);
51 tempPrint((-l) >>> 2);
52 tempPrint(l << 1);
53 }
54
55 private static int returnOneInt() {
56 return 1;
57 }
58
59 private static long returnOneLong() {
60 return 1;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected