void res_negative_delta(t_dis *delta) { float x1; float x2; float root; char val[32]; root = mt_fsqrt(delta->dis); ft_putendl("The discriminent is stricly negative, \ there is two complexes solutions:"); x1 = (-1 * delta->coef[B_COEF]) / (2 * delta->coef[A_COEF]); x2 = (mt_fsqrt(ABS(delta->dis))) / (2 * delta->coef[A_COEF]); if (x1 < 0) ft_putchar('-'); ft_ftoa(ABS(x1), val, 6); ft_putstr(val); ft_putstr(" +i * "); ft_ftoa(ABS(x2), val, 6); ft_putendl(val); if (x1 < 0) ft_putchar('-'); ft_ftoa(ABS(x1), val, 6); ft_putstr(val); ft_putstr(" -i * "); ft_ftoa(ABS(x2), val, 6); ft_putendl(val); }
void res_negative_delta(t_dis *delta) { float x1; float x2; float root; char val[32]; root = mt_fsqrt(delta->dis); ft_putendl(NEG_DELTA); x1 = (-1 * delta->coef[B_COEF]) / (2 * delta->coef[A_COEF]); x2 = (mt_fsqrt(ABS(delta->dis))) / (2 * delta->coef[A_COEF]); ft_putstr("X1 = "); if (x1 < 0) ft_putchar('-'); ft_ftoa(ABS(x1), val, 6); ft_putstr(val); ft_putstr(" +i * "); ft_ftoa(ABS(x2), val, 6); ft_putendl(val); if (x1 < 0) ft_putchar('-'); ft_ftoa(ABS(x1), val, 6); ft_putstr("X2 = "); ft_putstr(val); ft_putstr(" -i * "); ft_ftoa(ABS(x2), val, 6); ft_putendl(val); }
static void s_float_check(t_printf *t) { char *str; if (t->flags.spec == 'f') { t->work_buffer = ft_ftoa( t->flags.number.longdouble, t->flags.prec); if (t->flags.number.longdouble != t->flags.number.longdouble) t->flags.prec = -1; } else if (t->flags.spec == 'F') { t->work_buffer = ft_ftoa( t->flags.number.longdouble, t->flags.prec); if (t->flags.number.longdouble != t->flags.number.longdouble) t->flags.prec = -1; str = ft_strmap(t->work_buffer, &s_toupper); ft_strdel(&t->work_buffer); t->work_buffer = str; } }
char *ft_dtos(double n, int precision) { char *str; char *tmps; double tmp; int pow; char *exp; pow = 0; tmp = n; while (tmp > 10) { pow++; tmp /= 10; } tmps = ft_ftoa(tmp, precision); str = ft_strjoin(tmps, "e+"); free(tmps); tmps = ft_strdup(str); free(str); if (pow < 10) exp = ft_strjoin("0", ft_itoa(pow)); else exp = ft_strjoin("", ft_itoa(pow)); str = ft_strjoin(tmps, exp); free(tmps); return (str); }
void ft_putfloat(float n) { char *str; str = ft_ftoa(n); ft_putstr(str); ft_strdel(&str); }
int compute_f_flag(va_list *ap, t_arg args) { double nbr; char *text; nbr = va_arg(*ap, double); text = ft_ftoa(nbr, args); return (ft_print_str(text, args, 10)); }
void res_positive_delta(t_dis *delta) { float x1; float x2; float root; char val[32]; root = mt_fsqrt(delta->dis); x1 = (-1 * delta->coef[B_COEF] - root) / (2 * delta->coef[A_COEF]); x2 = (-1 * delta->coef[B_COEF] + root) / (2 * delta->coef[A_COEF]); ft_putendl("The discriminent is stricly positive, \ there is two real solutions:"); if (x1 < 0) ft_putchar('-'); ft_ftoa(ABS(x1), val, 6); ft_putendl(val); if (x2 < 0) ft_putchar('-'); ft_ftoa(ABS(x2), val, 6); ft_putendl(val); }
void res_positive_delta(t_dis *delta) { float x1; float x2; float root; char val[32]; root = mt_fsqrt(delta->dis); x1 = (-1 * delta->coef[B_COEF] - root) / (2 * delta->coef[A_COEF]); x2 = (-1 * delta->coef[B_COEF] + root) / (2 * delta->coef[A_COEF]); ft_putendl(POS_DELTA); ft_putstr("X1 = "); if (x1 < 0) ft_putchar('-'); ft_ftoa(ABS(x1), val, 6); ft_putendl(val); ft_putstr("X2 = "); if (x2 < 0) ft_putchar('-'); ft_ftoa(ABS(x2), val, 6); ft_putendl(val); }
void res_null_delta(t_dis *delta) { float x1; float root; char val[32]; root = mt_fsqrt(delta->dis); x1 = (-1 * delta->coef[B_COEF]) / 2 * delta->coef[A_COEF]; ft_putendl("The discriminent is stricly null, \ there is a unique real solution:"); if (x1 < 0) ft_putchar('-'); ft_ftoa(ABS(x1), val, 6); ft_putendl(val); }
void res_null_delta(t_dis *delta) { float x1; float root; char val[32]; root = mt_fsqrt(delta->dis); x1 = (-1 * delta->coef[B_COEF]) / 2 * delta->coef[A_COEF]; ft_putendl(NUL_DELTA); if (x1 < 0) ft_putchar('-'); ft_ftoa(ABS(x1), val, 6); ft_putstr("X = "); ft_putendl(val); }
void red_put_polynom(float coef, float degree, int ieq, int flag) { char val[32]; ft_bzero(val, sizeof(char) * 32); coef *= ieq > 0 ? 1 : -1; if (flag) coef >= 0 ? ft_putstr("+ ") : ft_putstr ("- "); else if (coef < 0) ft_putstr ("-"); ft_ftoa(ABS(coef), val, 2); ft_putstr(val); ft_putstr(" * X^"); ft_putnbr(degree); ft_putchar(' '); }
void number_type(void) { if (sgt_printf()->flags.spec == 'f') sgt_printf()->work_buffer = ft_ftoa( sgt_printf()->flags.number.longdouble, sgt_printf()->flags.prec); else if (sgt_printf()->flags.spec == 'b') sgt_printf()->work_buffer = ft_ubasetoa( sgt_printf()->flags.number.longlong, "01"); else if (sgt_printf()->flags.spec == 'x') sgt_printf()->work_buffer = ft_ubasetoa( sgt_printf()->flags.number.longlong, "0123456789abcdef"); else if (sgt_printf()->flags.spec == 'X') sgt_printf()->work_buffer = ft_ubasetoa( sgt_printf()->flags.number.longlong, "0123456789ABCDEF"); else if (sgt_printf()->flags.base == 8) sgt_printf()->work_buffer = ft_ubasetoa( sgt_printf()->flags.number.longlong, "01234567"); else sgt_printf()->work_buffer = ft_ubasetoa( sgt_printf()->flags.number.longlong, "0123456789"); }