From 6f50dd4aab99ef95bbcda4ce731d2fca116df3ce Mon Sep 17 00:00:00 2001 From: BillKek <51540758+BillKek@users.noreply.github.com> Date: Sun, 28 Feb 2021 01:07:53 +0300 Subject: [PATCH] fixed precision commit. was assert-fail on negative numbers. --- conversions/c_atoi_str_to_integer.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/conversions/c_atoi_str_to_integer.c b/conversions/c_atoi_str_to_integer.c index fe316527..fce10cc9 100644 --- a/conversions/c_atoi_str_to_integer.c +++ b/conversions/c_atoi_str_to_integer.c @@ -30,9 +30,15 @@ int c_atoi(const char *str) /* store the sign if it is negative sign */ if (str[i] == '-') + { sign = -1; + i++; + } else if (str[i] == '+') + { sign = 1; + i++; + } /* converting char by char to a numeric value */ while (str[i] >= 48 && str[i] <= 57 && str[i] != '\0')