Time for an 2014 update…
This commit is contained in:
parent
372c577f83
commit
09687c4926
2520 changed files with 34227 additions and 7318 deletions
|
|
@ -1,20 +1,20 @@
|
|||
#define std'dictionary'*.
|
||||
#define std'basic'*.
|
||||
#define system.
|
||||
#define extensions.
|
||||
|
||||
#symbol BitwiseTest &former:anA &later:aB =
|
||||
#symbol bitwiseTest = (:x:y)
|
||||
[
|
||||
'program'output << anA << " and " << aB << " = " << anA and:aB << "%n".
|
||||
'program'output << anA << " or " << aB << " = " << anA or:aB << "%n".
|
||||
'program'output << anA << " xor " << aB << " = " << anA xor:aB << "%n".
|
||||
'program'output << "not " << anA << " = " << anA inverted << "%n".
|
||||
'program'output << anA << " shr " << aB << " = " << anA __shift'add:aB << "%n".
|
||||
'program'output << anA << " shl " << aB << " = " << anA __shift'subtract:aB << "%n".
|
||||
console write:x write:" and " write:y write:" = " writeLine:(x and:y).
|
||||
console write:x write:" or " write:y write:" = " writeLine:(x or:y).
|
||||
console write:x write:" xor " write:y write:" = " writeLine:(x xor:y).
|
||||
console write:"not " write:x write:" = " writeLine:(x not).
|
||||
console write:x write:" shr " write:y write:" = " writeLine:(x shift:y).
|
||||
console write:x write:" shl " write:y write:" = " writeLine:(x shift:(y negative)).
|
||||
].
|
||||
|
||||
#symbol Program =
|
||||
#symbol program =
|
||||
[
|
||||
#var a := 'program'input >> Integer.
|
||||
#var b := 'program'input >> Integer.
|
||||
#var a := consoleEx readLine:(Integer new).
|
||||
#var b := consoleEx readLine:(Integer new).
|
||||
|
||||
BitwiseTest &&former:a &later:b.
|
||||
bitwiseTest:a:b.
|
||||
].
|
||||
|
|
|
|||
12
Task/Bitwise-operations/Rust/bitwise-operations.rust
Normal file
12
Task/Bitwise-operations/Rust/bitwise-operations.rust
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
fn main() {
|
||||
let a: u8 = 105;
|
||||
let b: u8 = 91;
|
||||
println!("a = {:0>8t}", a);
|
||||
println!("b = {:0>8t}", b);
|
||||
println!("a | b = {:0>8t}", a | b);
|
||||
println!("a & b = {:0>8t}", a & b);
|
||||
println!("a ^ b = {:0>8t}", a ^ b);
|
||||
println!("!a = {:0>8t}", !a);
|
||||
println!("a << 3 = {:0>8t}", a >> 3);
|
||||
println!("a >> 3 = {:0>8t}", a << 3);
|
||||
}
|
||||
30
Task/Bitwise-operations/Seed7/bitwise-operations.seed7
Normal file
30
Task/Bitwise-operations/Seed7/bitwise-operations.seed7
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
$ include "seed7_05.s7i";
|
||||
include "bin32.s7i";
|
||||
|
||||
const proc: bitwise (in integer: a, in integer: b) is func
|
||||
begin
|
||||
writeln("a: " <& a radix 2 lpad0 32);
|
||||
writeln("b: " <& b radix 2 lpad0 32);
|
||||
writeln("integer operations:");
|
||||
writeln("a << b: " <& a << b radix 2 lpad0 32); # left shift
|
||||
writeln("a >> b: " <& a >> b radix 2 lpad0 32); # arithmetic right shift
|
||||
end func;
|
||||
|
||||
const proc: bitwise (in bin32: a, in bin32: b) is func
|
||||
begin
|
||||
writeln("bin32 operations:");
|
||||
writeln("a and b: " <& a & b radix 2 lpad0 32);
|
||||
writeln("a or b: " <& a | b radix 2 lpad0 32);
|
||||
writeln("a xor b: " <& a >< b radix 2 lpad0 32);
|
||||
writeln("not a: " <& ~a radix 2 lpad0 32);
|
||||
writeln("a << b: " <& a << ord(b) radix 2 lpad0 32); # left shift
|
||||
writeln("a >> b: " <& a >> ord(b) radix 2 lpad0 32); # logical right shift
|
||||
writeln("a rotL b: " <& rotLeft(a, ord(b)) radix 2 lpad0 32); # Rotate Left
|
||||
writeln("a rolR b: " <& rotRight(a, ord(b)) radix 2 lpad0 32); # Rotate Right
|
||||
end func;
|
||||
|
||||
const proc: main is func
|
||||
begin
|
||||
bitwise(65076, 6);
|
||||
bitwise(bin32(65076), bin32(6));
|
||||
end func;
|
||||
Loading…
Add table
Add a link
Reference in a new issue