public static void putLongNullable(ByteBuffer out, Long x)
    {
        if (x == null) 
        {
            out.put( NULL );
        }
        else
        {
            long value = (x < 0 ? -x : x);
            int sign = (x < 0 ? BYTE_SIGN_NEG : BYTE_SIGN_POS);
            long a = (value & 0x1F);
            int more = (value >>= 5) != 0 ? BYTE_MORE : 0;
            
            out.put( (byte)(more | sign | BYTE_NOT_NULL | a) );
            
            while (more != 0)
            {
                a = value & 0x7F;
                more = (value >>= 7) != 0 ? BYTE_MORE : 0;
                out.put( (byte)(more | a) );
            }
        }
    }