September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -1,27 +1,23 @@
/*REXX program performs bitwise operations on integers: & | && ¬ «L »R */
numeric digits 1000 /*be able to handle some big integers. */
say center('decimal', 9) center("value", 9) center('bits', 50)
say copies('' , 9) copies("" , 9) copies('', 50)
a = 21 ; call show a , 'A' /* show & tell A */
b = 3 ; call show b , 'B' /* show & tell B */
call show bAnd(a,b) , 'A & B' /* and */
call show bOr( a,b) , 'A | B' /* or */
call show bXOr(a,b) , 'A && B' /* xor */
call show bNot(a) , '¬ A' /* not */
call show bShiftL(a,b) , 'A [«B]' /* shift left */
call show bShiftR(a,b) , 'A [»B]' /* shirt right */
/*REXX program performs bit─wise operations on integers: & | && ¬ «L »R */
numeric digits 1000 /*be able to handle ginormous integers.*/
say center('decimal', 9) center("value", 9) center('bits', 50)
say copies('' , 9) copies("" , 9) copies('', 50)
a = 21 ; call show a , 'A' /* display A */
b = 3 ; call show b , 'B' /* display B */
call show bAnd(a, b) , 'A & B' /* and */
call show bOr(a, b) , 'A | B' /* or */
call show bXor(a, b) , 'A && B' /* xor */
call show bNot(a) , '¬ A' /* not */
call show bShiftL(a, b) , 'A [«B]' /* shift left */
call show bShiftR(a, b) , 'A [»B]' /* shirt right */
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
show: procedure; parse arg x,t; say right(x,9) center(t,9) right(d2b(x),50); return
d2b: return x2b(d2x(arg(1))) +0 /*some REXXes have the D2B BIF. */
b2d: return x2d(b2x(arg(1))) /* " " " " B2D " */
bNot: return b2d(translate(d2b(arg(1)), 10, 01)) +0 /*+0 ≡ normalizes the number*/
bShiftL: return (b2d(d2b(arg(1)) || copies(0, arg(2)))) +0 /* " " " " " */
bAnd: procedure; parse arg x,y; return c2d(bitand(d2c(x), d2c(y)))
bOr: procedure; parse arg x,y; return c2d(bitor( d2c(x), d2c(y)))
bXor: procedure; parse arg x,y; return c2d(bitxor(d2c(x), d2c(y)))
/*──────────────────────────────────────────────────────────────────────────────────────*/
bShiftR: procedure; parse arg x,y; $=substr(reverse(d2b(x)), y+1)
if $=='' then $=0; return b2d(reverse($))
show: say right( arg(1), 9) center( arg(2), 9) right( d2b( arg(1) ), 50); return
d2b: return x2b( d2x( arg(1) ) ) + 0 /*some REXXes have the D2B BIF. */
b2d: return x2d( b2x( arg(1) ) ) /* " " " " B2D " */
bNot: return b2d( translate( d2b( arg(1) ), 10, 01) ) +0 /*+0 ≡ normalizes a #.*/
bShiftL: return b2d( d2b( arg(1) ) || copies(0, arg(2) ) ) +0 /* " " " " " */
bAnd: return c2d( bitand( d2c( arg(1) ), d2c( arg(2) ) ) )
bOr: return c2d( bitor( d2c( arg(1) ), d2c( arg(2) ) ) )
bXor: return c2d( bitxor( d2c( arg(1) ), d2c( arg(2) ) ) )
bShiftR: $=substr(reverse(d2b(arg(1))),arg(2)+1); if $='' then $=0; return b2d(reverse($))