jaroslav@114: /** jaroslav@114: * Back 2 Browser Bytecode Translator jaroslav@114: * Copyright (C) 2012 Jaroslav Tulach jaroslav@114: * jaroslav@114: * This program is free software: you can redistribute it and/or modify jaroslav@114: * it under the terms of the GNU General Public License as published by jaroslav@114: * the Free Software Foundation, version 2 of the License. jaroslav@114: * jaroslav@114: * This program is distributed in the hope that it will be useful, jaroslav@114: * but WITHOUT ANY WARRANTY; without even the implied warranty of jaroslav@114: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the jaroslav@114: * GNU General Public License for more details. jaroslav@114: * jaroslav@114: * You should have received a copy of the GNU General Public License jaroslav@114: * along with this program. Look for COPYING file in the top folder. jaroslav@114: * If not, see http://opensource.org/licenses/GPL-2.0. jaroslav@114: */ jaroslav@114: package org.apidesign.vm4brwsr; jaroslav@114: jaroslav@181: import java.io.ByteArrayInputStream; jaroslav@181: import java.io.DataInputStream; jaroslav@181: import java.io.IOException; jaroslav@181: jaroslav@114: /** jaroslav@114: * jaroslav@114: * @author Jaroslav Tulach jaroslav@114: */ jaroslav@114: public class Numbers { jaroslav@114: private static Double autoboxDbl() { jaroslav@114: return 3.3; jaroslav@114: } jaroslav@114: public static String autoboxDblToString() { jaroslav@114: return autoboxDbl().toString().toString(); jaroslav@114: } jaroslav@178: public static int rem(int a, int b) { jaroslav@178: return a % b; jaroslav@178: } jaroslav@181: jaroslav@181: static float deserFloat() throws IOException { jaroslav@181: byte[] arr = {(byte) 71, (byte) 84, (byte) 52, (byte) 83}; jaroslav@181: ByteArrayInputStream is = new ByteArrayInputStream(arr); jaroslav@181: DataInputStream dis = new DataInputStream(is); jaroslav@181: float r = dis.readFloat(); jaroslav@181: return r; jaroslav@181: } jaroslav@185: static double deserDouble() throws IOException { jaroslav@185: byte[] arr = {(byte)64, (byte)8, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0}; jaroslav@185: ByteArrayInputStream is = new ByteArrayInputStream(arr); jaroslav@185: DataInputStream dis = new DataInputStream(is); jaroslav@185: return dis.readDouble(); jaroslav@185: } jaroslav@185: static long deserLong(byte[] arr) throws IOException { jaroslav@185: ByteArrayInputStream is = new ByteArrayInputStream(arr); jaroslav@185: DataInputStream dis = new DataInputStream(is); jaroslav@185: return dis.readLong(); jaroslav@185: } jaroslav@181: static int deserInt() throws IOException { jaroslav@181: byte[] arr = {(byte) 71, (byte) 84, (byte) 52, (byte) 83}; jaroslav@181: ByteArrayInputStream is = new ByteArrayInputStream(arr); jaroslav@181: DataInputStream dis = new DataInputStream(is); jaroslav@181: return dis.readInt(); jaroslav@181: } jaroslav@186: jaroslav@186: static String intToString() { jaroslav@186: return new Integer(5).toString().toString(); jaroslav@186: } jaroslav@187: static String floatToString() { jaroslav@187: return new Float(7.0).toString().toString(); jaroslav@187: } jaroslav@114: }