public Number toNumber(int size) {
        switch(size) {
            case 1:
                if(data.length > 1) { throw new IllegalArgumentException("invalid byte array length - " + data.length); }
                return (byte)toBigInteger().longValue();
            case 2:
                if(data.length > 2) { throw new IllegalArgumentException("invalid byte array length - " + data.length); }
                return (short)toBigInteger().longValue();
            case 4:
                if(data.length > 4) { throw new IllegalArgumentException("invalid byte array length - " + data.length); }
                return (int)toBigInteger().longValue();
            case 8:
                if(data.length > 8) { throw new IllegalArgumentException("invalid byte array length - " + data.length); }
                return toBigInteger().longValue();
            default:
                throw new IllegalArgumentException("unsupported size - " + size);
        }
    }