/*
** EPITECH PROJECT, 2018
** task01
** File description:
** I do task
*/
#include "lib/my_stdlib.h"

int my_atoi(const char *nptr)
{
    size_t neg;
    int result;

    nptr--;
    neg = 0;
    result = 0;
    while (*(++nptr) == '-' || *nptr == '+'
    || *nptr == '\t' || *nptr == ' '){
        neg = (*nptr == '-') ? 1 : neg;
        neg = (*nptr == '+') ? 0 : neg;
    }
    while (*(++nptr) >= '0' && *nptr <= '9')
        result = (result * 10) + *nptr - '0';
    return (neg ? -result : result);
}

long my_atol(const char *nptr)
{
    long result;
    size_t neg;

    nptr--;
    neg = 0;
    result = 0;
    while (*(++nptr) == '-' || *nptr == '+'
    || *nptr == '\t' || *nptr == ' '){
        neg = (*nptr == '-') ? 1 : neg;
        neg = (*nptr == '+') ? 0 : neg;
    }
    while (*(++nptr) >= '0' && *nptr <= '9')
        result = (result * 10) + *nptr - '0';
    return (neg ? -result : result);
}

long long my_atoll(const char *nptr)
{
    long long result;
    size_t neg;

    nptr--;
    neg = 0;
    result = 0;
    while (*(++nptr) == '-' || *nptr == '+'
    || *nptr == '\t' || *nptr == ' '){
        neg = (*nptr == '-') ? 1 : neg;
        neg = (*nptr == '+') ? 0 : neg;
    }
    while (*(++nptr) >= '0' && *nptr <= '9')
        result = (result * 10) + *nptr - '0';
    return (neg ? -result : result);
}
