pub unsafe extern "C" fn rb_integer_unpack(
words: *const c_void,
numwords: size_t,
wordsize: size_t,
nails: size_t,
flags: c_int,
) -> VALUEExpand description
Import an integer from a buffer.
@param[in] words Buffer to import.
@param[in] numwords Number of words of words.
@param[in] wordsize Number of bytes per word.
@param[in] nails Number of padding bits in a word. Most
significant nails bits of each word are ignored.
@param[in] flags Bitwise or of constants whose name starts
“INTEGER_PACK_”.
@exception rb_eArgError numwords * wordsize too big.
Possible flags are:
-
#INTEGER_PACK_MSWORD_FIRST: Interpret the first word as the most significant word.
-
#INTEGER_PACK_LSWORD_FIRST: Interpret the first word as the least significant word.
-
#INTEGER_PACK_MSBYTE_FIRST: Interpret the first byte in a word as the most significant byte in the word.
-
#INTEGER_PACK_LSBYTE_FIRST: Interpret the first byte in a word as the least significant byte in the word.
-
#INTEGER_PACK_NATIVE_BYTE_ORDER: Either #INTEGER_PACK_MSBYTE_FIRST or #INTEGER_PACK_LSBYTE_FIRST corresponding to the host’s endian.
-
#INTEGER_PACK_2COMP: Uses 2’s complement representation.
-
#INTEGER_PACK_LITTLE_ENDIAN: Shorthand of
INTEGER_PACK_LSWORD_FIRST|INTEGER_PACK_LSBYTE_FIRST -
#INTEGER_PACK_BIG_ENDIAN: Shorthand of
INTEGER_PACK_MSWORD_FIRST|INTEGER_PACK_MSBYTE_FIRST -
#INTEGER_PACK_FORCE_BIGNUM: Returns a bignum even if its value is representable as a fixnum.
-
#INTEGER_PACK_NEGATIVE: Returns a non-positive value. (Returns a non-negative value if not specified.)
-
#INTEGER_PACK_FORCE_GENERIC_IMPLEMENTATION: Uses generic implementation (for test and debug).
@return An instance of ::rb_cInteger whose value is the interpreted
words. The range of the result value depends on
#INTEGER_PACK_2COMP and #INTEGER_PACK_NEGATIVE.
When #INTEGER_PACK_2COMP is not set:
-
0 <= val < 2**(numwords*(wordsize*CHAR_BIT-nails))if!INTEGER_PACK_NEGATIVE -
-2**(numwords*(wordsize*CHAR_BIT-nails)) < val <= 0ifINTEGER_PACK_NEGATIVE
When #INTEGER_PACK_2COMP is set:
-
-2**(numwords*(wordsize*CHAR_BIT-nails)-1)<= val <=2**(numwords*(wordsize*CHAR_BIT-nails)-1)-1if!INTEGER_PACK_NEGATIVE -
-2**(numwords*(wordsize*CHAR_BIT-nails)) <= val <= -1ifINTEGER_PACK_NEGATIVE
Passing #INTEGER_PACK_2COMP without #INTEGER_PACK_NEGATIVE means sign
extension. #INTEGER_PACK_2COMP with #INTEGER_PACK_NEGATIVE means assuming
the higher bits are 1.
§Note that this function returns 0 when numwords is zero and
#INTEGER_PACK_2COMP is set but #INTEGER_PACK_NEGATIVE is not set.
Generated by rb-sys for Ruby mri-x86_64-linux-gnu-3.2.3