Doubt regarding fast i/o inline function

#define ull unsigned long long

inline ull getull()
{
    ull ch=gc(),n=0, s=1;
    for(;ch<'0'||ch>'9';ch=gc())
    {
        if(ch=='-')
        {
            s=-1;
            ch=gc();
            break;
        }
    }
    for(;ch>='0'&& ch<='9';ch=gc())
        n=(n<<3)+(n<<1)+ch-'0';
    return n*s;
}

My doubt is whether this function is correct or not, because as far i know in unsigned variables we cannot store negative value so i want to ask whether can we use this inline function to take negative input from buffer or not ?

Thanks!! :slight_smile:

You can try, cannot you?

1 Like

Thanks… it don’t work…
so should i remove the condition of checking whether ch==’-’ ?

It’s your code, so it’s up to you :wink:

1 Like