Integer Conversions of Bit Strings (MIT/GNU Scheme 12.0.90)

Previous: Modification of Bit Strings, Up: Bit Strings [Contents][Index]

### 9.6 Integer Conversions of Bit Strings

procedure: unsigned-integer->bit-string length integer ¶

  Both length and integer must be exact non-negative integers. Converts integer into a newly allocated bit string of length bits. Signals an error of type `condition-type:bad-range-argument` if integer is too large to be represented in length bits.

procedure: signed-integer->bit-string length integer ¶

  Length must be an exact non-negative integer, and integer may be any exact integer. Converts integer into a newly allocated bit string of length bits, using two’s complement encoding for negative numbers. Signals an error of type `condition-type:bad-range-argument` if integer is too large to be represented in length bits.

procedure: bit-string->unsigned-integer bit-string ¶
procedure: bit-string->signed-integer bit-string ¶

  Converts bit-string into an exact integer. `bit-string->signed-integer` regards bit-string as a two’s complement representation of a signed integer, and produces an integer of like sign and absolute value. `bit-string->unsigned-integer` regards bit-string as an unsigned quantity and converts to an integer accordingly.