printf/libft/src/ft_itodd.c

43 lines
1.2 KiB
C
Raw Normal View History

2023-04-15 06:55:33 +02:00
/* ************************************************************************** */
/* */
/* :::::::: */
2023-10-26 18:32:55 +02:00
/* ft_itodd.c :+: :+: */
2023-04-15 06:55:33 +02:00
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2021/01/31 03:00:29 by djonker #+# #+# */
2023-10-26 18:32:55 +02:00
/* Updated: 2023/10/18 16:59:34 by houtworm ######## odam.nl */
2023-04-15 06:55:33 +02:00
/* */
/* ************************************************************************** */
#include "../libft.h"
char *ft_itodd(double n)
{
char r[20];
int c;
double tf;
int ti;
char *s;
c = 0;
while (n != 0)
{
if (n < 12)
r[c] = ft_htod(n);
else if (n > 11)
{
tf = n / 12;
ti = n / 12;
tf = (tf - ti) * 12;
r[c] = ft_htod(tf);
}
ti = n / 12;
n = ti;
c++;
}
r[c] = '\0';
s = ft_revstr(r);
return (s);
}