/* ************************************************************************** */ /* */ /* :::::::: */ /* ft_around.c :+: :+: :+: */ /* +:+ */ /* By: djonker +#+ */ /* +#+ */ /* Created: 2021/02/02 07:26:00 by djonker #+# #+# */ /* Updated: 2023/02/07 00:42:07 by houtworm ### ########.fr */ /* */ /* ************************************************************************** */ #include "../libft.h" int ft_around(char *n, int e) { int i; i = 0; while (n[i] == '0') { e++; i++; } i = ft_strlen(n); while (i >= e) { if (n[i] >= '5') n[i - 1] = n[i - 1] + 1; while (n[i - 1] > '9') { n[i - 1] = '0'; n[i - 2] = n[i - 2] + 1; i--; if (i == 1 && n[0] > '9') return (1); } i--; } return (0); }