AnsweredAssumed Answered

LPC54xxx atol,atoi,strtol Redlib maximum input

Question asked by David Kaplan on Mar 10, 2019
Latest reply on Mar 12, 2019 by David Kaplan

I need to parse a decimal string representation of an unsigned 4 byte integer or long.

In my debugger I can see that when the 4 byte value string is 2943834865,

I get a result of 2147483647 (0x7fffffff) from atol,atoi and strtol .

 

 

    fileChecksum = atol(Ptr2);
    fileChecksum = strtol(Ptr2,&Ptr1,10);

 

The debugger:

Ptr2 -> Details:0x20002bd5 <g_bufferRead+13> "2943834865"

 

Name : fileChecksum
    Details:2147483647
    Default:2147483647
    Decimal:2147483647
    Hex:0x7fffffff
    Binary:1111111111111111111111111111111
    Octal:017777777777

 

I am guessing that this is because of an overflow from the signed value.

The fileChecksum I defined uint32_t and then as uint64_t with the same result.

 

Thanks

Outcomes