2

The INTERCAL select operator denoted by sqiggle(~) takes a selection of bits and compresses them to one end of a word.

Section 3.4.1 of the THE INTERCAL PROGRAMMING LANGUAGE REVISED REFERENCE MANUAL states:

The select operator takes from the first operand whichever bits correspond to 1’s in the second operand, and packs these bits to the right in the result. Both operands are automatically padded on the left with zeros to 32 bits before the selection takes place, so the variable types are unrestricted. If more than 16 bits are selected, the result is a 32-bit value, otherwise it is a 16-bit value. For example, #179˜#201 (binary value 10110011˜11001001) selects from the first argument the 8th, 7th, 4th, and 1st from last bits, namely, 1001, which = 9. But #201˜#179 selects from binary 11001001 the 8th, 6th, 5th, 2nd, and 1st from last bits, giving 10001 = 17. #179˜#179 has the value 31, while #201˜#201 has the value 15.

Is there a standard way of inverting this operation in INTERCAL or any other language?

And does the inverse have a name?

David
  • 121
  • 4

0 Answers0