55 lines
1.2 KiB
C
55 lines
1.2 KiB
C
/* printer.c */
|
|
|
|
#include "computorv1.h"
|
|
|
|
void print_debug(const char *description, ...)
|
|
{
|
|
if (!flag_debug_mode)
|
|
return;
|
|
|
|
// print the formatted description
|
|
va_list args;
|
|
va_start(args, description);
|
|
// ft_vdprintf(STDERR_FILENO, description, args); // it's not handling floats for the moment
|
|
vdprintf(STDERR_FILENO, description, args);
|
|
va_end(args);
|
|
}
|
|
|
|
void print_before_solution(double *polynom, int max_exponent)
|
|
{
|
|
int i;
|
|
|
|
// reduced form
|
|
ft_putstr("Reduced form: ");
|
|
i = max_exponent;
|
|
printf("%g * x^%i ", ft_fabs(polynom[i]), i);
|
|
fflush(stdout);
|
|
i--;
|
|
while (i >= 0)
|
|
{
|
|
if (polynom[i] >= 0)
|
|
{
|
|
ft_putchar('+');
|
|
}
|
|
else
|
|
{
|
|
ft_putchar('-');
|
|
}
|
|
printf(" %g * x^%i ", ft_fabs(polynom[i]), i);
|
|
fflush(stdout);
|
|
i--;
|
|
}
|
|
ft_putstr("= 0\n");
|
|
|
|
// // check errors
|
|
// ft_printf(": ");
|
|
// ft_printf(": ");
|
|
// ft_printf(": ");
|
|
|
|
// degree
|
|
ft_printf("Polynomial degree: %i\n", max_exponent);
|
|
if (max_exponent > 2)
|
|
{
|
|
stop_errors("The polynomial degree is strictly greater than 2, I can't solve.\n");
|
|
}
|
|
} |