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;
|
int j;
|
||||||
|
|
||||||
i = 1 << 12;
|
i = 1 << 12;
|
||||||
j = 4096;
|
// i = 4096;
|
||||||
while (i >>= 1)
|
while (i >>= 1)
|
||||||
(octet & i) ? ft_putnbr(1) : ft_putnbr(0);
|
(octet & i) ? ft_putnbr(1) : ft_putnbr(0);
|
||||||
ft_putchar('\n');
|
ft_putchar('\n');
|
||||||
while (j >>= 1)
|
|
||||||
(octet & j) ? ft_putnbr(1) : ft_putnbr(0);
|
|
||||||
ft_putchar('\n');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void compare(int initial, int compare)
|
void compare(int initial, int compare)
|
||||||
{
|
{
|
||||||
int i;
|
compare ^= (1 << 3);
|
||||||
int j;
|
print_bits(compare);
|
||||||
|
ft_putchar('\n');
|
||||||
|
|
||||||
i = 1 << 3;
|
/*
|
||||||
initial ^= i;
|
// il faut utiliser le & car il transforme
|
||||||
j = 1 << 12;
|
// 0+0=0 1+0=0 0+1=0 mais 1+1=1
|
||||||
while (j >>= 1)
|
// donc si rien ne se superpose on obtient 0
|
||||||
(initial & j) ? ft_putnbr(1) : ft_putnbr(0);
|
// et si un seul bit se superpose on obtient 1
|
||||||
ft_putchar('\n');
|
// (penser a l'utiliser a l'envers donc)
|
||||||
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
|
while (initial & compare)
|
||||||
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)
|
print_bits(initial);
|
||||||
j = 1 << 12;
|
print_bits(compare);
|
||||||
while (j >>= 1)
|
print_bits(initial & compare);
|
||||||
(initial | compare) & j ? ft_putnbr(1) : ft_putnbr(0);
|
!(initial & compare) ? ft_putendl("&: fit") : ft_putendl("&: not fit");
|
||||||
ft_putchar('\n');
|
compare <<= 1;
|
||||||
(initial | compare) ? ft_putendl("|: fit") : ft_putendl("|: not fit");
|
}
|
||||||
j = 1 << 12;
|
print_bits(initial);
|
||||||
while (j >>= 1)
|
print_bits(compare);
|
||||||
(initial ^ compare) & j ? ft_putnbr(1) : ft_putnbr(0);
|
print_bits(initial & compare);
|
||||||
ft_putchar('\n');
|
!(initial & compare) ? ft_putendl("&: fit") : ft_putendl("&: not fit");
|
||||||
(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)
|
int main(int ac, char **av)
|
||||||
@@ -48,8 +58,10 @@ int main(int ac, char **av)
|
|||||||
int i;
|
int i;
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
i = 56173;
|
// i = 56173;
|
||||||
j = 9362;
|
// j = 9362;
|
||||||
|
i = 9622;
|
||||||
|
j = 27;
|
||||||
if (ac > 0)
|
if (ac > 0)
|
||||||
{
|
{
|
||||||
if (ac > 1)
|
if (ac > 1)
|
||||||
|
|||||||
Reference in New Issue
Block a user