mirror of
https://github.com/TheAlgorithms/C
synced 2024-11-22 05:21:49 +03:00
fixed precision commit. was assert-fail on negative numbers.
This commit is contained in:
parent
28fc15c65b
commit
6f50dd4aab
@ -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')
|
||||
|
Loading…
Reference in New Issue
Block a user