View previous topic :: View next topic
|
Author |
Message |
John Duffy
New User
Joined: 07 Oct 2020 Posts: 2 Location: USA
|
|
|
|
Does REXX have an instruction or way to conduct a Test Under Mask like assembler does? I have a one byte binary field. I need to test if the third bit is on. Only the third bit. |
|
Back to top |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1306 Location: Bamberg, Germany
|
|
|
|
Code: |
BITAND (Bit by Bit AND)
+----------------------------------------------------------------------------+
| |
|>>---BITAND---(--string1---+----------------------------------+---)----->< |
| +--,--+------------+---+--------+--+ |
| +--string2---+ +--,pad--+ |
| |
+----------------------------------------------------------------------------+
returns a string composed of the two input strings logically ANDed
together, bit by bit. (The encoding of the strings are used in the logical
operation.) The length of the result is the length of the longer of the
two strings. If no pad character is provided, the AND operation stops when
the shorter of the two strings is exhausted, and the unprocessed portion
of the longer string is appended to the partial result. If pad is
provided, it extends the shorter of the two strings on the right before
carrying out the logical operation. The default for string2 is the zero
length (null) string. |
|
|
Back to top |
|
|
John Duffy
New User
Joined: 07 Oct 2020 Posts: 2 Location: USA
|
|
|
|
Thank You Sir! That worked brilliantly! |
|
Back to top |
|
|
Willy Jensen
Active Member
Joined: 01 Sep 2015 Posts: 724 Location: Denmark
|
|
|
|
or use c2x+x2b and then use the substr function.
i.e.:
v = '08'x
say x2b(c2x(v)) /* -> 00001000 */ |
|
Back to top |
|
|
|