java 16进制浮点数转十进制

    /**
     * 处理4个字节带小数的浮点数
     * Created by wuhaowei([email protected])
     *
     * @param b
     * @return
     * @DATE:2011-10-16 下午08:52:24
     */
    public static float byte2intFloat(byte b[]) {
        int bits = b[3] & 0xff | (b[2] & 0xff) << 8 | (b[1] & 0xff) << 16 | (b[0] & 0xff) << 24;
        int sign = ((bits & 0x80000000) == 0) ? 1 : -1;
        int exponent = ((bits & 0x7f800000) >> 23);
        int mantissa = (bits & 0x007fffff);
        mantissa |= 0x00800000;
        float f = (float) (sign * mantissa * Math.pow(2, exponent - 150));
        return f;
    }

你可能感兴趣的:(java)