boucle pour faire circuler le test dans la map
This commit is contained in:
70
test_mask.c
70
test_mask.c
@@ -6,41 +6,51 @@ void print_bits(int octet)
|
||||
int j;
|
||||
|
||||
i = 1 << 12;
|
||||
j = 4096;
|
||||
// i = 4096;
|
||||
while (i >>= 1)
|
||||
(octet & i) ? ft_putnbr(1) : ft_putnbr(0);
|
||||
ft_putchar('\n');
|
||||
while (j >>= 1)
|
||||
(octet & j) ? ft_putnbr(1) : ft_putnbr(0);
|
||||
ft_putchar('\n');
|
||||
}
|
||||
|
||||
void compare(int initial, int compare)
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
compare ^= (1 << 3);
|
||||
print_bits(compare);
|
||||
ft_putchar('\n');
|
||||
|
||||
i = 1 << 3;
|
||||
initial ^= i;
|
||||
j = 1 << 12;
|
||||
while (j >>= 1)
|
||||
(initial & j) ? ft_putnbr(1) : ft_putnbr(0);
|
||||
ft_putchar('\n');
|
||||
j = 1 << 12; // il faut utiliser le & car il transforme
|
||||
while (j >>= 1) // 0+0=0 1+0=0 0+1=0 mais 1+1=1
|
||||
(initial & compare) & j ? ft_putnbr(1) : ft_putnbr(0); // donc si rien ne se superpose on obtient 0
|
||||
ft_putchar('\n'); // et si un seul bit se superpose on obtient 1
|
||||
(initial & compare) ? ft_putendl("&: fit") : ft_putendl("&: not fit"); // (penser a l'utiliser a l'envers donc)
|
||||
j = 1 << 12;
|
||||
while (j >>= 1)
|
||||
(initial | compare) & j ? ft_putnbr(1) : ft_putnbr(0);
|
||||
ft_putchar('\n');
|
||||
(initial | compare) ? ft_putendl("|: fit") : ft_putendl("|: not fit");
|
||||
j = 1 << 12;
|
||||
while (j >>= 1)
|
||||
(initial ^ compare) & j ? ft_putnbr(1) : ft_putnbr(0);
|
||||
ft_putchar('\n');
|
||||
(initial ^ compare) ? ft_putendl("^: fit") : ft_putendl("^: not fit");
|
||||
/*
|
||||
// il faut utiliser le & car il transforme
|
||||
// 0+0=0 1+0=0 0+1=0 mais 1+1=1
|
||||
// donc si rien ne se superpose on obtient 0
|
||||
// et si un seul bit se superpose on obtient 1
|
||||
// (penser a l'utiliser a l'envers donc)
|
||||
*/
|
||||
|
||||
while (initial & compare)
|
||||
{
|
||||
print_bits(initial);
|
||||
print_bits(compare);
|
||||
print_bits(initial & compare);
|
||||
!(initial & compare) ? ft_putendl("&: fit") : ft_putendl("&: not fit");
|
||||
compare <<= 1;
|
||||
}
|
||||
print_bits(initial);
|
||||
print_bits(compare);
|
||||
print_bits(initial & compare);
|
||||
!(initial & compare) ? ft_putendl("&: fit") : ft_putendl("&: not fit");
|
||||
|
||||
/*
|
||||
// j = 1 << 12;
|
||||
// while (j >>= 1)
|
||||
// (initial | compare) & j ? ft_putnbr(1) : ft_putnbr(0);
|
||||
// ft_putchar('\n');
|
||||
// (initial | compare) ? ft_putendl("|: fit") : ft_putendl("|: not fit");
|
||||
// j = 1 << 12;
|
||||
// while (j >>= 1)
|
||||
// (initial ^ compare) & j ? ft_putnbr(1) : ft_putnbr(0);
|
||||
// ft_putchar('\n');
|
||||
// (initial ^ compare) ? ft_putendl("^: fit") : ft_putendl("^: not fit");
|
||||
*/
|
||||
}
|
||||
|
||||
int main(int ac, char **av)
|
||||
@@ -48,8 +58,10 @@ int main(int ac, char **av)
|
||||
int i;
|
||||
int j;
|
||||
|
||||
i = 56173;
|
||||
j = 9362;
|
||||
// i = 56173;
|
||||
// j = 9362;
|
||||
i = 9622;
|
||||
j = 27;
|
||||
if (ac > 0)
|
||||
{
|
||||
if (ac > 1)
|
||||
|
||||
Reference in New Issue
Block a user