/* ************************************************************************** */ /* */ /* :::::::: */ /* ft_round.c :+: :+: :+: */ /* +:+ */ /* By: djonker +#+ */ /* +#+ */ /* Created: 2021/02/02 07:26:00 by djonker #+# #+# */ /* Updated: 2023/02/07 00:40:48 by houtworm ### ########.fr */ /* */ /* ************************************************************************** */ #include "../libft.h" int ft_round(int n, int h) { int ht; ht = h; if ((n % 10) > 5) n = n + 1; while (ht > 0) { if ((n % 10) > 5) { n = n / 10; n = n + 1; } else n = n / 10; ht--; } while (h > 0) { n = n * 10; h--; } return (n); }