init
This commit is contained in:
27
It_Test.java
Normal file
27
It_Test.java
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
public class It_Test{
|
||||||
|
|
||||||
|
static int i = 1;
|
||||||
|
|
||||||
|
public static int iterator(){
|
||||||
|
i = i * 2;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void printBinary(int num) {
|
||||||
|
for (int shift = 31; shift >= 0; --shift) {
|
||||||
|
System.out.print((num >> shift) & 1);
|
||||||
|
}
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args){
|
||||||
|
boolean run = true;
|
||||||
|
while(run){
|
||||||
|
int next = iterator();
|
||||||
|
System.out.println("Int: " + next);
|
||||||
|
System.out.print("Bin: ");
|
||||||
|
printBinary(next);
|
||||||
|
run = next != 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
31
it_test.c
Normal file
31
it_test.c
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int i = 1;
|
||||||
|
|
||||||
|
int iterator() {
|
||||||
|
i = i * 2;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_binary(unsigned int num) {
|
||||||
|
for (int i = sizeof(num) * 8 - 1; i >= 0; --i) {
|
||||||
|
printf("%d", (num >> i) & 1);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int run = 1;
|
||||||
|
while (run) {
|
||||||
|
int next = iterator();
|
||||||
|
printf("Int: %d\n", next);
|
||||||
|
printf("Bin: ");
|
||||||
|
print_binary(next);
|
||||||
|
// printf("Continue? [y]/n\n");
|
||||||
|
// char c = scanf("%c", &c);
|
||||||
|
// if (c == 'n') {
|
||||||
|
// run = 0;
|
||||||
|
// }
|
||||||
|
run = next;
|
||||||
|
}
|
||||||
|
}
|
18
it_test.py
Normal file
18
it_test.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
def iterator():
|
||||||
|
i = 1
|
||||||
|
while True:
|
||||||
|
yield i
|
||||||
|
i = i * 2
|
||||||
|
|
||||||
|
|
||||||
|
def print_binary(num):
|
||||||
|
print(f"Bin: {num:032b}")
|
||||||
|
|
||||||
|
|
||||||
|
run = 1
|
||||||
|
gen = iterator()
|
||||||
|
while run != 0:
|
||||||
|
nextv = next(gen)
|
||||||
|
print(f"Int: {nextv}")
|
||||||
|
print_binary(nextv)
|
||||||
|
run = nextv
|
26
it_test.rs
Normal file
26
it_test.rs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
static mut I: i32 = 1;
|
||||||
|
|
||||||
|
fn iterator() -> i32 {
|
||||||
|
unsafe {
|
||||||
|
I = I << 1;
|
||||||
|
I
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn print_binary(num: i32) {
|
||||||
|
for shift in (0..32).rev() {
|
||||||
|
print!("{}", (num >> shift) & 1);
|
||||||
|
}
|
||||||
|
println!();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let mut run = 1;
|
||||||
|
while run != 0 {
|
||||||
|
let next = iterator();
|
||||||
|
println!("Int: {}", next);
|
||||||
|
print!("Bin: ");
|
||||||
|
print_binary(next);
|
||||||
|
run = next;
|
||||||
|
}
|
||||||
|
}
|
10
test.sh
Normal file
10
test.sh
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/sh
|
||||||
|
|
||||||
|
rustc -o it_test_rs it_test.rs
|
||||||
|
gcc -o it_test_c it_test.c
|
||||||
|
javac It_Test.java
|
||||||
|
|
||||||
|
./it_test_rs > test_rust.txt
|
||||||
|
./it_test_c > test_c.txt
|
||||||
|
java It_Test > test_java.txt
|
||||||
|
python it_test.py > test_python.txt
|
64
test_c.txt
Normal file
64
test_c.txt
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
Int: 2
|
||||||
|
Bin: 00000000000000000000000000000010
|
||||||
|
Int: 4
|
||||||
|
Bin: 00000000000000000000000000000100
|
||||||
|
Int: 8
|
||||||
|
Bin: 00000000000000000000000000001000
|
||||||
|
Int: 16
|
||||||
|
Bin: 00000000000000000000000000010000
|
||||||
|
Int: 32
|
||||||
|
Bin: 00000000000000000000000000100000
|
||||||
|
Int: 64
|
||||||
|
Bin: 00000000000000000000000001000000
|
||||||
|
Int: 128
|
||||||
|
Bin: 00000000000000000000000010000000
|
||||||
|
Int: 256
|
||||||
|
Bin: 00000000000000000000000100000000
|
||||||
|
Int: 512
|
||||||
|
Bin: 00000000000000000000001000000000
|
||||||
|
Int: 1024
|
||||||
|
Bin: 00000000000000000000010000000000
|
||||||
|
Int: 2048
|
||||||
|
Bin: 00000000000000000000100000000000
|
||||||
|
Int: 4096
|
||||||
|
Bin: 00000000000000000001000000000000
|
||||||
|
Int: 8192
|
||||||
|
Bin: 00000000000000000010000000000000
|
||||||
|
Int: 16384
|
||||||
|
Bin: 00000000000000000100000000000000
|
||||||
|
Int: 32768
|
||||||
|
Bin: 00000000000000001000000000000000
|
||||||
|
Int: 65536
|
||||||
|
Bin: 00000000000000010000000000000000
|
||||||
|
Int: 131072
|
||||||
|
Bin: 00000000000000100000000000000000
|
||||||
|
Int: 262144
|
||||||
|
Bin: 00000000000001000000000000000000
|
||||||
|
Int: 524288
|
||||||
|
Bin: 00000000000010000000000000000000
|
||||||
|
Int: 1048576
|
||||||
|
Bin: 00000000000100000000000000000000
|
||||||
|
Int: 2097152
|
||||||
|
Bin: 00000000001000000000000000000000
|
||||||
|
Int: 4194304
|
||||||
|
Bin: 00000000010000000000000000000000
|
||||||
|
Int: 8388608
|
||||||
|
Bin: 00000000100000000000000000000000
|
||||||
|
Int: 16777216
|
||||||
|
Bin: 00000001000000000000000000000000
|
||||||
|
Int: 33554432
|
||||||
|
Bin: 00000010000000000000000000000000
|
||||||
|
Int: 67108864
|
||||||
|
Bin: 00000100000000000000000000000000
|
||||||
|
Int: 134217728
|
||||||
|
Bin: 00001000000000000000000000000000
|
||||||
|
Int: 268435456
|
||||||
|
Bin: 00010000000000000000000000000000
|
||||||
|
Int: 536870912
|
||||||
|
Bin: 00100000000000000000000000000000
|
||||||
|
Int: 1073741824
|
||||||
|
Bin: 01000000000000000000000000000000
|
||||||
|
Int: -2147483648
|
||||||
|
Bin: 10000000000000000000000000000000
|
||||||
|
Int: 0
|
||||||
|
Bin: 00000000000000000000000000000000
|
64
test_java.txt
Normal file
64
test_java.txt
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
Int: 2
|
||||||
|
Bin: 00000000000000000000000000000010
|
||||||
|
Int: 4
|
||||||
|
Bin: 00000000000000000000000000000100
|
||||||
|
Int: 8
|
||||||
|
Bin: 00000000000000000000000000001000
|
||||||
|
Int: 16
|
||||||
|
Bin: 00000000000000000000000000010000
|
||||||
|
Int: 32
|
||||||
|
Bin: 00000000000000000000000000100000
|
||||||
|
Int: 64
|
||||||
|
Bin: 00000000000000000000000001000000
|
||||||
|
Int: 128
|
||||||
|
Bin: 00000000000000000000000010000000
|
||||||
|
Int: 256
|
||||||
|
Bin: 00000000000000000000000100000000
|
||||||
|
Int: 512
|
||||||
|
Bin: 00000000000000000000001000000000
|
||||||
|
Int: 1024
|
||||||
|
Bin: 00000000000000000000010000000000
|
||||||
|
Int: 2048
|
||||||
|
Bin: 00000000000000000000100000000000
|
||||||
|
Int: 4096
|
||||||
|
Bin: 00000000000000000001000000000000
|
||||||
|
Int: 8192
|
||||||
|
Bin: 00000000000000000010000000000000
|
||||||
|
Int: 16384
|
||||||
|
Bin: 00000000000000000100000000000000
|
||||||
|
Int: 32768
|
||||||
|
Bin: 00000000000000001000000000000000
|
||||||
|
Int: 65536
|
||||||
|
Bin: 00000000000000010000000000000000
|
||||||
|
Int: 131072
|
||||||
|
Bin: 00000000000000100000000000000000
|
||||||
|
Int: 262144
|
||||||
|
Bin: 00000000000001000000000000000000
|
||||||
|
Int: 524288
|
||||||
|
Bin: 00000000000010000000000000000000
|
||||||
|
Int: 1048576
|
||||||
|
Bin: 00000000000100000000000000000000
|
||||||
|
Int: 2097152
|
||||||
|
Bin: 00000000001000000000000000000000
|
||||||
|
Int: 4194304
|
||||||
|
Bin: 00000000010000000000000000000000
|
||||||
|
Int: 8388608
|
||||||
|
Bin: 00000000100000000000000000000000
|
||||||
|
Int: 16777216
|
||||||
|
Bin: 00000001000000000000000000000000
|
||||||
|
Int: 33554432
|
||||||
|
Bin: 00000010000000000000000000000000
|
||||||
|
Int: 67108864
|
||||||
|
Bin: 00000100000000000000000000000000
|
||||||
|
Int: 134217728
|
||||||
|
Bin: 00001000000000000000000000000000
|
||||||
|
Int: 268435456
|
||||||
|
Bin: 00010000000000000000000000000000
|
||||||
|
Int: 536870912
|
||||||
|
Bin: 00100000000000000000000000000000
|
||||||
|
Int: 1073741824
|
||||||
|
Bin: 01000000000000000000000000000000
|
||||||
|
Int: -2147483648
|
||||||
|
Bin: 10000000000000000000000000000000
|
||||||
|
Int: 0
|
||||||
|
Bin: 00000000000000000000000000000000
|
28570
test_python.txt
Normal file
28570
test_python.txt
Normal file
File diff suppressed because one or more lines are too long
64
test_rust.txt
Normal file
64
test_rust.txt
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
Int: 2
|
||||||
|
Bin: 00000000000000000000000000000010
|
||||||
|
Int: 4
|
||||||
|
Bin: 00000000000000000000000000000100
|
||||||
|
Int: 8
|
||||||
|
Bin: 00000000000000000000000000001000
|
||||||
|
Int: 16
|
||||||
|
Bin: 00000000000000000000000000010000
|
||||||
|
Int: 32
|
||||||
|
Bin: 00000000000000000000000000100000
|
||||||
|
Int: 64
|
||||||
|
Bin: 00000000000000000000000001000000
|
||||||
|
Int: 128
|
||||||
|
Bin: 00000000000000000000000010000000
|
||||||
|
Int: 256
|
||||||
|
Bin: 00000000000000000000000100000000
|
||||||
|
Int: 512
|
||||||
|
Bin: 00000000000000000000001000000000
|
||||||
|
Int: 1024
|
||||||
|
Bin: 00000000000000000000010000000000
|
||||||
|
Int: 2048
|
||||||
|
Bin: 00000000000000000000100000000000
|
||||||
|
Int: 4096
|
||||||
|
Bin: 00000000000000000001000000000000
|
||||||
|
Int: 8192
|
||||||
|
Bin: 00000000000000000010000000000000
|
||||||
|
Int: 16384
|
||||||
|
Bin: 00000000000000000100000000000000
|
||||||
|
Int: 32768
|
||||||
|
Bin: 00000000000000001000000000000000
|
||||||
|
Int: 65536
|
||||||
|
Bin: 00000000000000010000000000000000
|
||||||
|
Int: 131072
|
||||||
|
Bin: 00000000000000100000000000000000
|
||||||
|
Int: 262144
|
||||||
|
Bin: 00000000000001000000000000000000
|
||||||
|
Int: 524288
|
||||||
|
Bin: 00000000000010000000000000000000
|
||||||
|
Int: 1048576
|
||||||
|
Bin: 00000000000100000000000000000000
|
||||||
|
Int: 2097152
|
||||||
|
Bin: 00000000001000000000000000000000
|
||||||
|
Int: 4194304
|
||||||
|
Bin: 00000000010000000000000000000000
|
||||||
|
Int: 8388608
|
||||||
|
Bin: 00000000100000000000000000000000
|
||||||
|
Int: 16777216
|
||||||
|
Bin: 00000001000000000000000000000000
|
||||||
|
Int: 33554432
|
||||||
|
Bin: 00000010000000000000000000000000
|
||||||
|
Int: 67108864
|
||||||
|
Bin: 00000100000000000000000000000000
|
||||||
|
Int: 134217728
|
||||||
|
Bin: 00001000000000000000000000000000
|
||||||
|
Int: 268435456
|
||||||
|
Bin: 00010000000000000000000000000000
|
||||||
|
Int: 536870912
|
||||||
|
Bin: 00100000000000000000000000000000
|
||||||
|
Int: 1073741824
|
||||||
|
Bin: 01000000000000000000000000000000
|
||||||
|
Int: -2147483648
|
||||||
|
Bin: 10000000000000000000000000000000
|
||||||
|
Int: 0
|
||||||
|
Bin: 00000000000000000000000000000000
|
Reference in New Issue
Block a user