01: /* *****************************************************************************
02: * MathUtils.java
03: * ****************************************************************************/
04:
05: /* J_LZ_COPYRIGHT_BEGIN *******************************************************
06: * Copyright 2001-2004 Laszlo Systems, Inc. All Rights Reserved. *
07: * Use is subject to license terms. *
08: * J_LZ_COPYRIGHT_END *********************************************************/
09:
10: package org.openlaszlo.utils;
11:
12: import java.lang.Math;
13:
14: /**
15: * A utility class containing math utility functions.
16: */
17:
18: public class MathUtils {
19: /**
20: * @param d the double to format
21: * @param n the number of places past the decimal place
22: */
23: public static String formatDouble(double d, int n) {
24: int x = (int) Math.pow(10, n);
25: return Double.toString((double) (((int) (x * d)) / (double) x));
26:
27: }
28:
29: /**
30: * @return hex representation of byte.
31: */
32: public static String byteToHexString(byte b) {
33: int left = (int) ((b & 0xf0) >> 4);
34: int right = (int) (b & 0x0f);
35: return Integer.toHexString(left) + Integer.toHexString(right);
36: }
37: }
|