pub unsafe extern "C" fn rb_integer_pack(
val: VALUE,
words: *mut c_void,
numwords: size_t,
wordsize: size_t,
nails: size_t,
flags: c_int,
) -> c_intExpand description
Exports an integer into a buffer. This function fills the buffer specified
by words and numwords as val in the format specified by wordsize,
nails and flags.
@param[in] val Integer or integer-like object which has
#to_int method.
@param[out] words Return buffer.
@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 filled
by zero.
@param[in] flags Bitwise or of constants whose name starts
“INTEGER_PACK_”.
@exception rb_eTypeError val doesn’t respond to #to_int.
Possible flags are:
-
#INTEGER_PACK_MSWORD_FIRST: Stores the most significant word as the first word.
-
#INTEGER_PACK_LSWORD_FIRST: Stores the least significant word as the first word.
-
#INTEGER_PACK_MSBYTE_FIRST: Stores the most significant byte in a word as the first byte in the word.
-
#INTEGER_PACK_LSBYTE_FIRST: Stores the least significant byte in a word as the first 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_GENERIC_IMPLEMENTATION: Uses generic implementation (for test and debug).
This function fills the buffer specified by words as val’s 2’s
complement representation if #INTEGER_PACK_2COMP is specified in flags.
Otherwise it fills words as abs(val) and signedness is returned via the
return value.
@return The signedness and overflow condition. The overflow condition depends on #INTEGER_PACK_2COMP.
When #INTEGER_PACK_2COMP is not specified:
-
-2: Negative overflow.val <= -2**(numwords*(wordsize*CHAR_BIT-nails)) -
-1: Negative without overflow.-2**(numwords*(wordsize*CHAR_BIT-nails)) < val < 0 -
0: zero.val == 0 -
1: Positive without overflow.0 < val < 2**(numwords*(wordsize*CHAR_BIT-nails)) -
2: Positive overflow.2**(numwords*(wordsize*CHAR_BIT-nails)) <= val
When #INTEGER_PACK_2COMP is specified:
-
-2: Negative overflow.val < -2**(numwords*(wordsize*CHAR_BIT-nails)) -
-1: Negative without overflow.-2**(numwords*(wordsize*CHAR_BIT-nails)) <= val < 0 -
0: zero.val == 0 -
1: Positive without overflow.0 < val < 2**(numwords*(wordsize*CHAR_BIT-nails)) -
2: Positive overflow.2**(numwords*(wordsize*CHAR_BIT-nails)) <= val
The value, -2**(numwords*(wordsize*CHAR_BIT-nails)), is representable in
2’s complement representation but not representable in absolute value. So
-1 is returned for the value if #INTEGER_PACK_2COMP is specified but
returns -2 if #INTEGER_PACK_2COMP is not specified.
§The least significant words are filled in the buffer when overflow occur.
Generated by rb-sys for Ruby mri-x86_64-linux-gnu-3.2.3