<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>LPC MicrocontrollersのトピックRe: LPC54xxx atol,atoi,strtol Redlib maximum input</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC54xxx-atol-atoi-strtol-Redlib-maximum-input/m-p/881082#M35238</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why not use strtoul? This converts to unsigned long.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 12 Mar 2019 14:14:31 GMT</pubDate>
    <dc:creator>converse</dc:creator>
    <dc:date>2019-03-12T14:14:31Z</dc:date>
    <item>
      <title>LPC54xxx atol,atoi,strtol Redlib maximum input</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC54xxx-atol-atoi-strtol-Redlib-maximum-input/m-p/881078#M35234</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need to parse a decimal string representation of an &lt;STRONG&gt;unsigned&lt;/STRONG&gt; 4 byte integer or long.&lt;/P&gt;&lt;P&gt;In my debugger I can see that when the 4 byte value string is 2943834865,&lt;/P&gt;&lt;P&gt;I get a result of 2147483647 (0x7fffffff) from atol,atoi and strtol .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fileChecksum = atol(Ptr2);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;fileChecksum = strtol(Ptr2,&amp;amp;Ptr1,10);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The debugger:&lt;/P&gt;&lt;P&gt;Ptr2 -&amp;gt; Details:0x20002bd5 &amp;lt;g_bufferRead+13&amp;gt; "2943834865"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Name : fileChecksum&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;Details:2147483647&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;Default:2147483647&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;Decimal:2147483647&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;Hex:0x7fffffff&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;Binary:1111111111111111111111111111111&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;Octal:017777777777&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am guessing that this is because of an overflow from the signed value.&lt;/P&gt;&lt;P&gt;The fileChecksum I defined uint32_t and then as uint64_t with the same result.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 10 Mar 2019 10:06:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC54xxx-atol-atoi-strtol-Redlib-maximum-input/m-p/881078#M35234</guid>
      <dc:creator>kiryat8</dc:creator>
      <dc:date>2019-03-10T10:06:04Z</dc:date>
    </item>
    <item>
      <title>Re: LPC54xxx atol,atoi,strtol Redlib maximum input</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC54xxx-atol-atoi-strtol-Redlib-maximum-input/m-p/881079#M35235</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I also tried to enter the checksum string in hex format and got the same results 0x7fffffff&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Today the checksum string was checksum=2939504859=0xAF3548DB.&lt;/P&gt;&lt;P&gt;I tried to enter "AF3548DB" with the strtol function set at base 16.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;fileChecksum = strtol(Ptr2,&amp;amp;Ptr1,16);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There may be a linker or compiler setting.&lt;/P&gt;&lt;P&gt;I may just break the string into two parts but other places in my code I use the atoi,atol functions andthe problem may not have yet surfaced.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Mar 2019 14:35:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC54xxx-atol-atoi-strtol-Redlib-maximum-input/m-p/881079#M35235</guid>
      <dc:creator>kiryat8</dc:creator>
      <dc:date>2019-03-11T14:35:06Z</dc:date>
    </item>
    <item>
      <title>Re: LPC54xxx atol,atoi,strtol Redlib maximum input</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC54xxx-atol-atoi-strtol-Redlib-maximum-input/m-p/881080#M35236</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;this function for example atol is defined as:&lt;/P&gt;&lt;P&gt;long int atol(const char *nptr);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here GNU defined long max as 0x7FFFFFFF(2^31-1), so anything larger than that will out put 0x7FFFFFFF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have a great day,&lt;BR /&gt;Jun Zhang&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-------------------------------------------------------------------------------&lt;BR /&gt;Note:&lt;BR /&gt;- If this post answers your question, please click the "Mark Correct" button. Thank you!&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- We are following threads for 7 weeks after the last post, later replies are ignored&lt;BR /&gt; Please open a new thread and refer to the closed one, if you have a related question at a later point in time.&lt;BR /&gt;-------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Mar 2019 07:47:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC54xxx-atol-atoi-strtol-Redlib-maximum-input/m-p/881080#M35236</guid>
      <dc:creator>ZhangJennie</dc:creator>
      <dc:date>2019-03-12T07:47:06Z</dc:date>
    </item>
    <item>
      <title>Re: LPC54xxx atol,atoi,strtol Redlib maximum input</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC54xxx-atol-atoi-strtol-Redlib-maximum-input/m-p/881081#M35237</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I knew the size of a signed long but never thought they would think to cap results that actually fit into an unsigned long.&lt;/P&gt;&lt;P&gt;I guess I never noticed this and will have to check the places I use atoi &amp;amp; atol.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Mar 2019 11:45:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC54xxx-atol-atoi-strtol-Redlib-maximum-input/m-p/881081#M35237</guid>
      <dc:creator>kiryat8</dc:creator>
      <dc:date>2019-03-12T11:45:43Z</dc:date>
    </item>
    <item>
      <title>Re: LPC54xxx atol,atoi,strtol Redlib maximum input</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC54xxx-atol-atoi-strtol-Redlib-maximum-input/m-p/881082#M35238</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why not use strtoul? This converts to unsigned long.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Mar 2019 14:14:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC54xxx-atol-atoi-strtol-Redlib-maximum-input/m-p/881082#M35238</guid>
      <dc:creator>converse</dc:creator>
      <dc:date>2019-03-12T14:14:31Z</dc:date>
    </item>
    <item>
      <title>Re: LPC54xxx atol,atoi,strtol Redlib maximum input</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC54xxx-atol-atoi-strtol-Redlib-maximum-input/m-p/881083#M35239</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you. Of course strtoul is what I was looking for. It works without problem. It makes sense to have strtoul and also strtol which I tried previously, but when you are used to the automatic conversion between signed and unsigned stuff in C, I did not think of it.&lt;/P&gt;&lt;P&gt;The no unsigned integers in Java is just crazy.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Mar 2019 05:54:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC54xxx-atol-atoi-strtol-Redlib-maximum-input/m-p/881083#M35239</guid>
      <dc:creator>kiryat8</dc:creator>
      <dc:date>2019-03-13T05:54:09Z</dc:date>
    </item>
  </channel>
</rss>

