public float get_halffloat(int offset)
    {
        int signbit;
        int mantissa;
        int exp;
        float result;
        if(offset >= 0)
                
        if (pb[5] < (offset + 2))
        {
            val = -1;   // insufficient payload length
            return 0;
        } 
        result = ((pb[offset + 7] & 0x80) != 0) ? (float) -1.0 : (float) 1.0;
        mantissa = ((((int) pb[offset + 7]) & 0x3) << 8) | (((int) pb[offset + 6]) & 0xff);
        exp = (pb[offset + 7] & 0x7c) >> 2;
//System.out.println("pb[offset+7] pb[offset + 6]: " + pb[offset + 7] + " " + pb[offset +6]
//              + "  exp:  " + exp + "  mantissa:  " + mantissa );
        if (exp != 0)
        {   //  non-zero exponent
            //  subtracting 1 from exp is required so that left shift by 
            //  exp == 31 does not produce negative result.  Compensated for in
            //  exponent of scaling factor following if expression
            result *= ((float) ((1 << HALF_MBITS) + mantissa)) 
                    * ((float) ( 1 << exp - 1));
        }
        else
        {   //  0 exponent
            result *= mantissa;
        }
        result *= ((float) 1.0) / (float) (1 << (HALF_EBIAS + HALF_MBITS - 1));
        return result;
    }