<?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 HC08: Why sprintf does not work correctly ? in CodeWarrior for MCU</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC08-Why-sprintf-does-not-work-correctly/m-p/137784#M2052</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;Hello,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;What is wrong with that:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;unsugned char str[70];&lt;/DIV&gt;&lt;DIV&gt;sprintf (str, "Offset = %0.3f\n",0.12345);&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;But If I'm printing out str, I receive "Offset = 1.497" instead of "Offset = 0.123" !&lt;/DIV&gt;&lt;DIV&gt;In the past, as&amp;nbsp;I remember, I already encountered such a problem and then I fixed it by casting of 0.12345 to (double)0.12345 because it states in CodeWarrior manual on sprintf page that "The argument must be a &lt;SPAN style="font-family: Arial;"&gt;double".But now suddenly it is not working.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-family: Arial;"&gt;Double means 64 bit in my understanding so I tested in the "MMDS-MMEVS Settings" that double is indeed 64 bit rather than 32. There is a check box DOUBLE is IEEE32 and this option is not checked, so I assume&amp;nbsp;double is actually 64.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-family: Arial;"&gt;If I compiling this&amp;nbsp;code in an other C compler (Bloodshed DEV-C++ 4.9.9.2&amp;nbsp;),&amp;nbsp;it is working !&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-family: Arial;"&gt;So how can I&amp;nbsp;fix the problem ?&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-family: Arial;"&gt;Thanks in advance to any replier.&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;p.s. I work with HC08 3.1 build 4210&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;Message Edited by CrasyCat on &lt;SPAN class="date_text"&gt;2007-04-13&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;11:46 AM&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 23 Nov 2006 16:11:33 GMT</pubDate>
    <dc:creator>Theprophet</dc:creator>
    <dc:date>2006-11-23T16:11:33Z</dc:date>
    <item>
      <title>HC08: Why sprintf does not work correctly ?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC08-Why-sprintf-does-not-work-correctly/m-p/137784#M2052</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;Hello,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;What is wrong with that:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;unsugned char str[70];&lt;/DIV&gt;&lt;DIV&gt;sprintf (str, "Offset = %0.3f\n",0.12345);&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;But If I'm printing out str, I receive "Offset = 1.497" instead of "Offset = 0.123" !&lt;/DIV&gt;&lt;DIV&gt;In the past, as&amp;nbsp;I remember, I already encountered such a problem and then I fixed it by casting of 0.12345 to (double)0.12345 because it states in CodeWarrior manual on sprintf page that "The argument must be a &lt;SPAN style="font-family: Arial;"&gt;double".But now suddenly it is not working.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-family: Arial;"&gt;Double means 64 bit in my understanding so I tested in the "MMDS-MMEVS Settings" that double is indeed 64 bit rather than 32. There is a check box DOUBLE is IEEE32 and this option is not checked, so I assume&amp;nbsp;double is actually 64.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-family: Arial;"&gt;If I compiling this&amp;nbsp;code in an other C compler (Bloodshed DEV-C++ 4.9.9.2&amp;nbsp;),&amp;nbsp;it is working !&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-family: Arial;"&gt;So how can I&amp;nbsp;fix the problem ?&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-family: Arial;"&gt;Thanks in advance to any replier.&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;p.s. I work with HC08 3.1 build 4210&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;Message Edited by CrasyCat on &lt;SPAN class="date_text"&gt;2007-04-13&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;11:46 AM&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Nov 2006 16:11:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC08-Why-sprintf-does-not-work-correctly/m-p/137784#M2052</guid>
      <dc:creator>Theprophet</dc:creator>
      <dc:date>2006-11-23T16:11:33Z</dc:date>
    </item>
    <item>
      <title>Re: Why sprintf does not work correctly ?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC08-Why-sprintf-does-not-work-correctly/m-p/137785#M2053</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hello&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Just tried it with a brand new project and I get it working.&lt;/DIV&gt;&lt;DIV&gt;Can you please check following points:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; - you should include St.h in the source file where you are doing the sprintf&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; - which is&amp;nbsp; compiler options are you using?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; You can see the command line arguments in the following way:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - Open target setting dialog (press ALT + F7)&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - Go to "Compiler for HC08" panel. What is written in Command Lines Arguments there?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; - Which ANSI library file are you linking to your application? If you are using 64-bit double, HCS08&amp;nbsp;and&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; small memory model it should be ansis.lib.&lt;/DIV&gt;&lt;DIV&gt;CrasyCat&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Nov 2006 18:38:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC08-Why-sprintf-does-not-work-correctly/m-p/137785#M2053</guid>
      <dc:creator>CrasyCat</dc:creator>
      <dc:date>2006-11-23T18:38:22Z</dc:date>
    </item>
    <item>
      <title>Re: Why sprintf does not work correctly ?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC08-Why-sprintf-does-not-work-correctly/m-p/137786#M2054</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Dear Sir,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;1) You say I should include St.h. Did you mean String.h ?&amp;nbsp;String.h is included in the appropriate source file, otherwise I could not compile a code with uknown function.&lt;/DIV&gt;&lt;DIV&gt;2) The only compile option, I checked, is Memory Model (Small)&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;3) I have ansif.lib linked to my app. Should I replace it with ansis.lib ? If so, how can I do it ?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Best Regards.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Nov 2006 19:11:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC08-Why-sprintf-does-not-work-correctly/m-p/137786#M2054</guid>
      <dc:creator>Theprophet</dc:creator>
      <dc:date>2006-11-23T19:11:00Z</dc:date>
    </item>
    <item>
      <title>Re: Why sprintf does not work correctly ?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC08-Why-sprintf-does-not-work-correctly/m-p/137787#M2055</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hello&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Oups spell checker did change the name of the file. You have to include stdio.h.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;If you have only defined option -Ms, you have to link with ansi.lib.&lt;/DIV&gt;&lt;DIV&gt;Remove ansif.lib from the project and add the file ansi.lib (it is located in {Install}\lib\hc08c\lib directory)&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;CrasyCat&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Nov 2006 22:49:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC08-Why-sprintf-does-not-work-correctly/m-p/137787#M2055</guid>
      <dc:creator>CrasyCat</dc:creator>
      <dc:date>2006-11-23T22:49:59Z</dc:date>
    </item>
    <item>
      <title>Re: Why sprintf does not work correctly ?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC08-Why-sprintf-does-not-work-correctly/m-p/137788#M2056</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Dear CrazyCat,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Replacing ansif.lib with ansi.lib has indeed solved the problem. But why ?&lt;/DIV&gt;&lt;DIV&gt;I have never payd attention to this difference between ansi.lib and ansif.lib. Now I've checked my previous project, based&amp;nbsp;on the same chip, and it also has ansif.lib included. So, I'd like to understand all the implications of this change, perhaps it can bring me some benefits, for example better code optimization etc.&lt;/DIV&gt;&lt;DIV&gt;Do you know where can I read about this issue ? In the HC08 manual I didn't find anything.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thank you very much.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Nov 2006 23:43:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC08-Why-sprintf-does-not-work-correctly/m-p/137788#M2056</guid>
      <dc:creator>Theprophet</dc:creator>
      <dc:date>2006-11-23T23:43:15Z</dc:date>
    </item>
    <item>
      <title>Re: Why sprintf does not work correctly ?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC08-Why-sprintf-does-not-work-correctly/m-p/137789#M2057</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;check the readme.txt in lib\hc08c&lt;BR /&gt;The floating point format for the application and the ANSI library has to match.&lt;BR /&gt;&lt;BR /&gt;Daniel&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Nov 2006 08:00:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC08-Why-sprintf-does-not-work-correctly/m-p/137789#M2057</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2006-11-24T08:00:34Z</dc:date>
    </item>
  </channel>
</rss>

