Data update
This commit is contained in:
parent
4d5544505c
commit
4924dd0264
3073 changed files with 55820 additions and 4408 deletions
|
|
@ -1,8 +1,13 @@
|
|||
main:(
|
||||
BEGIN
|
||||
|
||||
BITS all bits mask = NOT 16r0;
|
||||
LONG BITS long bits mask = LENG all bits mask;
|
||||
|
||||
PRIO SLC = 8, SRC = 8; # SLC and SRC are not built in, define and overload them here #
|
||||
OP SLC = (BITS b, INT rotate) BITS: b SHL rotate OR b SHR ( bits width - rotate );
|
||||
OP SRC = (BITS b, INT rotate) BITS: b SHR rotate OR b SHL ( bits width - rotate );
|
||||
OP SRC = (BITS b, INT rotate) BITS: b SHR rotate OR SHORTEN ( long bits mask
|
||||
AND ( LENG b SHL ( bits width - rotate ) )
|
||||
);
|
||||
# SRC and SRL are non-standard, but versions are built in to ALGOL 68R's standard prelude #
|
||||
|
||||
PRIO XOR = 2;
|
||||
|
|
@ -10,7 +15,10 @@ main:(
|
|||
# XOR is non-standard, but a version is built in to ALGOL 68G's standard prelude #
|
||||
|
||||
# ALGOL 68 has 5 different ways of representing a BINary BITS - Bases: 2, 4, 8, 16 and flip/flop #
|
||||
FORMAT b5 = $"2r"2r32d," 4r"4r16d," 8r"8r11d," 16r"16r8d," "gl$;
|
||||
FORMAT b5 = IF bits width > 32
|
||||
THEN $"2r"2r64d," 4r"4r32d,l" 8r"8r22d," 16r"16r16d,l" "gl$
|
||||
ELSE $"2r"2r32d," 4r"4r16d," 8r"8r11d," 16r"16r8d,l" "gl$
|
||||
FI;
|
||||
OP BBBBB = (BITS b)[]BITS: (b,b,b,b,b);
|
||||
|
||||
PROC bitwise = (BITS a, BITS b, INT shift)VOID:
|
||||
|
|
@ -61,4 +69,4 @@ CO
|
|||
bitwise(8r377,8r252,5);
|
||||
bitwise(16rff,16raa,5)
|
||||
END CO
|
||||
)
|
||||
END
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
create or replace function task(a,b) as table (
|
||||
select a, b, a&b, a|b, xor(a, b), ~a, a << b, a >> b
|
||||
);
|
||||
|
||||
from task(10, 2);
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
select 10 as v,
|
||||
~(v::BITSTRING),
|
||||
~(v::INT) as "~INT",
|
||||
~(v::BIGINT) as "~BIGINT",
|
||||
~(10::UINTEGER) as "~UINTEGER";
|
||||
|
|
@ -2,18 +2,18 @@ import extensions;
|
|||
|
||||
extension testOp
|
||||
{
|
||||
bitwiseTest(y)
|
||||
{
|
||||
console.printLine(self," and ",y," = ",self & y);
|
||||
console.printLine(self," or ",y," = ",self | y);
|
||||
console.printLine(self," xor ",y," = ",self ^ y);
|
||||
console.printLine("not ",self," = ",self.BInverted);
|
||||
console.printLine(self," shr ",y," = ",self.shiftRight(y));
|
||||
console.printLine(self," shl ",y," = ",self.shiftLeft(y));
|
||||
}
|
||||
bitwiseTest(y)
|
||||
{
|
||||
Console.printLine(self," and ",y," = ",self.band(y));
|
||||
Console.printLine(self," or ",y," = ",self.bor(y));
|
||||
Console.printLine(self," xor ",y," = ",self.bxor(y));
|
||||
Console.printLine("not ",self," = ",self.BInverted);
|
||||
Console.printLine(self," shr ",y," = ",self.shiftRight(y));
|
||||
Console.printLine(self," shl ",y," = ",self.shiftLeft(y));
|
||||
}
|
||||
}
|
||||
|
||||
public program()
|
||||
{
|
||||
console.loadLineTo(new Integer()).bitwiseTest(console.loadLineTo(new Integer()))
|
||||
Console.loadLineTo(new Integer()).bitwiseTest(Console.loadLineTo(new Integer()))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
link bitint # for int2bit
|
||||
|
||||
procedure main()
|
||||
bitdemo(255,2)
|
||||
bitdemo(-15,3)
|
||||
|
|
|
|||
20
Task/Bitwise-operations/Pluto/bitwise-operations.pluto
Normal file
20
Task/Bitwise-operations/Pluto/bitwise-operations.pluto
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
-- Rotate left and right are not built-in but we use the
|
||||
-- same 32-bit substitutes as in the Lua 5.3+ example.
|
||||
local function rl(x, y) return ((x << y) & 0xffffffff) | (x >> (32 - y)) end
|
||||
|
||||
local function rr(x, y) return (x >> y) | ((x << (32 - y)) & 0xffffffff) end
|
||||
|
||||
local function bitwise(x, y)
|
||||
print($" x = {x}")
|
||||
print($" y = {y}")
|
||||
print($" x & y = {x & y}")
|
||||
print($" x | y = {x | y}")
|
||||
print($" x ~ y = {x ~ y}")
|
||||
print($"~x = {~x}")
|
||||
print($" x << y = {x << y}")
|
||||
print($" x >> y = {x >> y}")
|
||||
print($" x rl y = {rl(x, y)}")
|
||||
print($" x rr y = {rr(x, y)}")
|
||||
end
|
||||
|
||||
bitwise(10, 2)
|
||||
Loading…
Add table
Add a link
Reference in a new issue