jaroslav@114
|
1 |
/**
|
jaroslav@114
|
2 |
* Back 2 Browser Bytecode Translator
|
jaroslav@114
|
3 |
* Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
|
jaroslav@114
|
4 |
*
|
jaroslav@114
|
5 |
* This program is free software: you can redistribute it and/or modify
|
jaroslav@114
|
6 |
* it under the terms of the GNU General Public License as published by
|
jaroslav@114
|
7 |
* the Free Software Foundation, version 2 of the License.
|
jaroslav@114
|
8 |
*
|
jaroslav@114
|
9 |
* This program is distributed in the hope that it will be useful,
|
jaroslav@114
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
jaroslav@114
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
jaroslav@114
|
12 |
* GNU General Public License for more details.
|
jaroslav@114
|
13 |
*
|
jaroslav@114
|
14 |
* You should have received a copy of the GNU General Public License
|
jaroslav@114
|
15 |
* along with this program. Look for COPYING file in the top folder.
|
jaroslav@114
|
16 |
* If not, see http://opensource.org/licenses/GPL-2.0.
|
jaroslav@114
|
17 |
*/
|
jaroslav@114
|
18 |
package org.apidesign.vm4brwsr;
|
jaroslav@114
|
19 |
|
jaroslav@181
|
20 |
import java.io.ByteArrayInputStream;
|
jaroslav@181
|
21 |
import java.io.DataInputStream;
|
jaroslav@181
|
22 |
import java.io.IOException;
|
jaroslav@181
|
23 |
|
jaroslav@114
|
24 |
/**
|
jaroslav@114
|
25 |
*
|
jaroslav@114
|
26 |
* @author Jaroslav Tulach <jtulach@netbeans.org>
|
jaroslav@114
|
27 |
*/
|
jaroslav@114
|
28 |
public class Numbers {
|
jaroslav@114
|
29 |
private static Double autoboxDbl() {
|
jaroslav@114
|
30 |
return 3.3;
|
jaroslav@114
|
31 |
}
|
jaroslav@114
|
32 |
public static String autoboxDblToString() {
|
jaroslav@114
|
33 |
return autoboxDbl().toString().toString();
|
jaroslav@114
|
34 |
}
|
jaroslav@178
|
35 |
public static int rem(int a, int b) {
|
jaroslav@178
|
36 |
return a % b;
|
jaroslav@178
|
37 |
}
|
jaroslav@181
|
38 |
|
jaroslav@181
|
39 |
static float deserFloat() throws IOException {
|
jaroslav@181
|
40 |
byte[] arr = {(byte) 71, (byte) 84, (byte) 52, (byte) 83};
|
jaroslav@181
|
41 |
ByteArrayInputStream is = new ByteArrayInputStream(arr);
|
jaroslav@181
|
42 |
DataInputStream dis = new DataInputStream(is);
|
jaroslav@181
|
43 |
float r = dis.readFloat();
|
jaroslav@181
|
44 |
return r;
|
jaroslav@181
|
45 |
}
|
jaroslav@185
|
46 |
static double deserDouble() throws IOException {
|
jaroslav@185
|
47 |
byte[] arr = {(byte)64, (byte)8, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0};
|
jaroslav@185
|
48 |
ByteArrayInputStream is = new ByteArrayInputStream(arr);
|
jaroslav@185
|
49 |
DataInputStream dis = new DataInputStream(is);
|
jaroslav@185
|
50 |
return dis.readDouble();
|
jaroslav@185
|
51 |
}
|
jaroslav@185
|
52 |
static long deserLong(byte[] arr) throws IOException {
|
jaroslav@185
|
53 |
ByteArrayInputStream is = new ByteArrayInputStream(arr);
|
jaroslav@185
|
54 |
DataInputStream dis = new DataInputStream(is);
|
jaroslav@185
|
55 |
return dis.readLong();
|
jaroslav@185
|
56 |
}
|
jaroslav@181
|
57 |
static int deserInt() throws IOException {
|
jaroslav@181
|
58 |
byte[] arr = {(byte) 71, (byte) 84, (byte) 52, (byte) 83};
|
jaroslav@181
|
59 |
ByteArrayInputStream is = new ByteArrayInputStream(arr);
|
jaroslav@181
|
60 |
DataInputStream dis = new DataInputStream(is);
|
jaroslav@181
|
61 |
return dis.readInt();
|
jaroslav@181
|
62 |
}
|
jaroslav@186
|
63 |
|
jaroslav@186
|
64 |
static String intToString() {
|
jaroslav@186
|
65 |
return new Integer(5).toString().toString();
|
jaroslav@186
|
66 |
}
|
jaroslav@187
|
67 |
static String floatToString() {
|
jaroslav@187
|
68 |
return new Float(7.0).toString().toString();
|
jaroslav@187
|
69 |
}
|
jaroslav@114
|
70 |
}
|