Jump to content

Bitwise operations: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 2,069:
 
=={{header|Maple}}==
Rotations and Arithmetic shifts are unavailable.
<lang Maple>
with(Bits):
bit:=proc(A,B)
local a,b,c,d,e,f,g,h,i,x,bitpow;
bitpow := 2^B:
a:=And(A,B);
b:=Not(A);
Line 2,079:
d:=Xor(A,B);
#Left Shift
e:=A* irem(2^B*A,bitpow);
#Right Shift
f :=A/ iquo(A,2^B);
#Left Rotate
return a,b,c,d,e,f;
g:= irem(2*A,bitpow,'x')+x;
#Rightarithshift
i:= iquo(A,2)+bitpow/2*irem(A,bitpow/2);
return a,b,c,d,e,f,g,i;
end proc;
bit := proc(A, B) ... end;
bit(8,12)
1
8, 7, 12, 4, 32768, ---
512
</lang>
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.