ajout de test pour faire tourner une grande map sur une petite
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
/* By: hulamy <hulamy@student.42.fr> +#+ +:+ +#+ */
|
/* By: hulamy <hulamy@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2019/04/14 15:20:53 by hulamy #+# #+# */
|
/* Created: 2019/04/14 15:20:53 by hulamy #+# #+# */
|
||||||
/* Updated: 2019/04/19 15:33:04 by hulamy ### ########.fr */
|
/* Updated: 2019/04/19 23:02:00 by hulamy ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ void print_bits(short line)
|
|||||||
{
|
{
|
||||||
int mask;
|
int mask;
|
||||||
|
|
||||||
mask = 1 << 16;
|
mask = 1 << 27;
|
||||||
while (mask >>= 1)
|
while (mask >>= 1)
|
||||||
(line & mask) ? ft_putnbr(1) : ft_putnbr(0);
|
(line & mask) ? ft_putnbr(1) : ft_putnbr(0);
|
||||||
ft_putchar('\n');
|
ft_putchar('\n');
|
||||||
@@ -35,7 +35,8 @@ void print_bits(short line)
|
|||||||
|
|
||||||
int fill_list(char *line, t_fillist *list)
|
int fill_list(char *line, t_fillist *list)
|
||||||
{
|
{
|
||||||
short tmp;
|
short tmp;
|
||||||
|
int test;
|
||||||
|
|
||||||
while (*line)
|
while (*line)
|
||||||
{
|
{
|
||||||
@@ -53,6 +54,10 @@ int fill_list(char *line, t_fillist *list)
|
|||||||
list->tibirtet <<= 1;
|
list->tibirtet <<= 1;
|
||||||
tmp >>= 1;
|
tmp >>= 1;
|
||||||
}
|
}
|
||||||
|
test = list->tibirtet;
|
||||||
|
print_bits(test);
|
||||||
|
while (test <<= 1)
|
||||||
|
print_bits(test);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
41
test_big_map.c
Normal file
41
test_big_map.c
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
void print_bits(int octet)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
i = 1 << 30;
|
||||||
|
while (i)
|
||||||
|
{
|
||||||
|
(octet & i) ? printf("1") : printf("0");
|
||||||
|
i >>= 1;
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void test(int map[])
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
print_bits(map[0]);
|
||||||
|
printf("\n");
|
||||||
|
while (i <= 30)
|
||||||
|
{
|
||||||
|
print_bits(map[1]);
|
||||||
|
// print_bits(((1 << i) & map[0]) << (30 - i));
|
||||||
|
map[1] = (map[1] >> 1) | (((1 << i) & map[0]) << (30 - i)); // cette ligne vient ajouter a la fin de map[1] le debut de map[0]
|
||||||
|
i++; // c'est brouillon mais ca permettrait de faire "tourner" sur une
|
||||||
|
} // seule petite map le contenu de la grande map divisee en tab de int
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int map[10] = {456873153, 1687645681, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
while (i < 10)
|
||||||
|
printf("%d\n", map[i++]);
|
||||||
|
test(map);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user