<?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>topic Re: Using type double in a program. in LPCXpresso IDE</title>
    <link>https://community.nxp.com/t5/LPCXpresso-IDE/Using-type-double-in-a-program/m-p/588990#M28413</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by CodeRedSupport on Sun Dec 09 05:47:33 MST 2012&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: IntStarFoo&lt;/STRONG&gt;&lt;BR /&gt;I got it working, but I'm still not exactly sure what the problem was.&amp;nbsp; Here are my steps for getting it working...&lt;BR /&gt;&lt;BR /&gt;1. Create a new project, add code, compile and run. (Works great.)&lt;BR /&gt;2. Compare project settings between my existing project and the new project and noticed a few things...&lt;BR /&gt;a. #include "stdio.h" in my was different than #include &amp;lt;stdio.h&amp;gt; so I changed that.&lt;BR /&gt;&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So you were using a local version of the stdio.h header file then? I suspect that the problem here is the your local header file does not actual declare fprintf in the same way that the C library actual defines it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you want to use the standard Redlib (or Newlib) C library functions, then you must be including the corresponding header files, not one from another source.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;CodeRedSupport&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 16 Jun 2016 01:21:34 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-16T01:21:34Z</dc:date>
    <item>
      <title>Using type double in a program.</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Using-type-double-in-a-program/m-p/588988#M28411</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by IntStarFoo on Sat Dec 08 16:15:10 MST 2012&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi There,&amp;nbsp; I have a problem using the type double in a program on LPC1769.&amp;nbsp; I can sort of demonstrate my issue using the code below... Can someone explain the results of this code?&amp;nbsp; The debugger appears to be showing it correctly but when it prints, it gives me unexpected results.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
double doubleA = 0;
double doubleB = 0;
double doubleC = 0;
fprintf(stdout, "Using %%d: doubleA:%d, doubleB:%d, doubleC:%d\n", doubleA, doubleB, doubleC);
fprintf(stdout, "Using %%f: doubleA:%f, doubleB:%f, doubleC:%f\n", doubleA, doubleB, doubleC);
doubleA = 0xFF;
doubleB = 0xFF + 0xFF;
doubleC = 0xFF * 0xFF;
fprintf(stdout, "Using %%d: doubleA:%d, doubleB:%d, doubleC:%d\n", doubleA, doubleB, doubleC);
fprintf(stdout, "Using %%f: doubleA:%f, doubleB:%f, doubleC:%f\n", doubleA, doubleB, doubleC);
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Produces These results...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Using %d: doubleA:0, doubleB:0, doubleC:0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Using %f: doubleA:, doubleB:, doubleC:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Using %d: doubleA:0, doubleB:1081073664, doubleC:0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Using %f: doubleA:, doubleB:, doubleC:&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 01:21:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Using-type-double-in-a-program/m-p/588988#M28411</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T01:21:33Z</dc:date>
    </item>
    <item>
      <title>Re: Using type double in a program.</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Using-type-double-in-a-program/m-p/588989#M28412</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by IntStarFoo on Sat Dec 08 17:34:04 MST 2012&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I got it working, but I'm still not exactly sure what the problem was.&amp;nbsp; Here are my steps for getting it working...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Create a new project, add code, compile and run. (Works great.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. Compare project settings between my existing project and the new project and noticed a few things...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;a. #include "stdio.h" in my was different than #include &amp;lt;stdio.h&amp;gt; so I changed that.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;b. Define order in the new project is: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;__REDLIB__&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;DEBUG&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;__CODE_RED&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;__USE_CMSIS=CMSISv2p00_LPC17xx&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Define order in old project was:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;DEBUG&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;__CODE_RED&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;__USE_CMSIS=CMSISv2p00_LPC17xx&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;__REDLIB__&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So I changed that to match &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;3.&amp;nbsp; Make changes to old project, compile and run.&amp;nbsp; (Works Great. - results below)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Using %d: doubleA:0, doubleB:0, doubleC:0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Using %f: doubleA:0.000000, doubleB:0.000000, doubleC:0.000000&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Using %d: doubleA:0, doubleB:1081073664, doubleC:0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Using %f: doubleA:255.000000, doubleB:510.000000, doubleC:65025.000000&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm guessing that somehow I was using some other version of some library that was giving unexpected results.&amp;nbsp; Either changing the define order or only looking in the C lib folders (via &amp;lt;stdio.h&amp;gt;) caught the right one.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;IntStarFoo&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 01:21:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Using-type-double-in-a-program/m-p/588989#M28412</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T01:21:34Z</dc:date>
    </item>
    <item>
      <title>Re: Using type double in a program.</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Using-type-double-in-a-program/m-p/588990#M28413</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by CodeRedSupport on Sun Dec 09 05:47:33 MST 2012&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: IntStarFoo&lt;/STRONG&gt;&lt;BR /&gt;I got it working, but I'm still not exactly sure what the problem was.&amp;nbsp; Here are my steps for getting it working...&lt;BR /&gt;&lt;BR /&gt;1. Create a new project, add code, compile and run. (Works great.)&lt;BR /&gt;2. Compare project settings between my existing project and the new project and noticed a few things...&lt;BR /&gt;a. #include "stdio.h" in my was different than #include &amp;lt;stdio.h&amp;gt; so I changed that.&lt;BR /&gt;&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So you were using a local version of the stdio.h header file then? I suspect that the problem here is the your local header file does not actual declare fprintf in the same way that the C library actual defines it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you want to use the standard Redlib (or Newlib) C library functions, then you must be including the corresponding header files, not one from another source.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;CodeRedSupport&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 01:21:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Using-type-double-in-a-program/m-p/588990#M28413</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T01:21:34Z</dc:date>
    </item>
  </channel>
</rss>

