| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | ** EPITECH PROJECT, 2023 | ||
| 3 | ** my_printf | ||
| 4 | ** File description: | ||
| 5 | ** Flag to print a %F (a double) | ||
| 6 | */ | ||
| 7 | |||
| 8 | #include <stdarg.h> | ||
| 9 | #include <stddef.h> | ||
| 10 | #include <stdlib.h> | ||
| 11 | #include "my.h" | ||
| 12 | #include "myformats.h" | ||
| 13 | |||
| 14 | 4 | static char *my_get_str_float(double nb, formating_t *formating) | |
| 15 | { | ||
| 16 | 4 | long long int partie_entiere = ABS((int)nb); | |
| 17 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
|
4 | double partie_d = ABS(nb - partie_entiere); |
| 18 | 4 | char *str_finale = malloc(sizeof(char) * 1000000); | |
| 19 | |||
| 20 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
|
4 | if (nb < 0){ |
| 21 | 3 | my_strcat(str_finale, "-"); | |
| 22 | 3 | nb = -nb; | |
| 23 | } | ||
| 24 | 4 | my_strcat(str_finale, my_str_nbr_long_long(partie_entiere)); | |
| 25 | 4 | precise_it_double(str_finale, formating, partie_d); | |
| 26 | 4 | format_it_double(str_finale, formating, partie_d); | |
| 27 | 4 | return my_strdup(str_finale); | |
| 28 | } | ||
| 29 | |||
| 30 | 4 | int flag_bigf(va_list list, formating_t *formating) | |
| 31 | { | ||
| 32 | 4 | char *temp = my_get_str_float(va_arg(list, double), formating); | |
| 33 | |||
| 34 | 4 | my_putstrf(formating->fd, temp); | |
| 35 | 4 | return my_strlen(temp); | |
| 36 | } | ||
| 37 |