jaroslav@0: /* jaroslav@0: Java 4 Browser Bytecode Translator jaroslav@0: Copyright (C) 2012-2012 Jaroslav Tulach jaroslav@0: jaroslav@0: This program is free software: you can redistribute it and/or modify jaroslav@0: it under the terms of the GNU General Public License as published by jaroslav@0: the Free Software Foundation, version 2 of the License. jaroslav@0: jaroslav@0: This program is distributed in the hope that it will be useful, jaroslav@0: but WITHOUT ANY WARRANTY; without even the implied warranty of jaroslav@0: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the jaroslav@0: GNU General Public License for more details. jaroslav@0: jaroslav@0: You should have received a copy of the GNU General Public License jaroslav@0: along with this program. Look for COPYING file in the top folder. jaroslav@0: If not, see http://opensource.org/licenses/GPL-2.0. jaroslav@0: */ jaroslav@0: package org.apidesign.java4browser; jaroslav@0: jaroslav@0: /** jaroslav@0: * jaroslav@0: * @author Jaroslav Tulach jaroslav@0: */ jaroslav@0: public class StaticMethod { jaroslav@0: public static int sum(int x, int y) { jaroslav@0: return x + y; jaroslav@0: } jaroslav@1: public static float power(float x) { jaroslav@1: return x * x; jaroslav@1: } jaroslav@2: public static double minus(double x, long y) { jaroslav@2: return x - y; jaroslav@2: } jaroslav@3: public static int div(byte c, double d) { jaroslav@3: return (int)(d / c); jaroslav@3: } jaroslav@3: public static int mix(int a, long b, byte c, double d) { jaroslav@3: return (int)((b / a + c) * d); jaroslav@3: } jaroslav@4: public static long factRec(int n) { jaroslav@4: if (n <= 1) { jaroslav@4: return 1; jaroslav@4: } else { jaroslav@4: return n * factRec(n - 1); jaroslav@4: } jaroslav@4: } jaroslav@5: public static long factIter(int n) { jaroslav@5: long res = 1; jaroslav@5: for (int i = 2; i <= n; i++) { jaroslav@5: res *= i; jaroslav@5: } jaroslav@5: return res; jaroslav@5: } jaroslav@0: }