<?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: Problem with sprintf and float in S12 / MagniV Microcontrollers</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-sprintf-and-float/m-p/133610#M1925</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;Including stdio.h should allow you to use sprintf without any problem.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;CodeWarrior for HC12 ANSI libraries does not include implementation for snprintf.&lt;/DIV&gt;&lt;DIV&gt;So that is&amp;nbsp;probably the reason you get your message.&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>Mon, 03 Nov 2008 18:51:40 GMT</pubDate>
    <dc:creator>CrasyCat</dc:creator>
    <dc:date>2008-11-03T18:51:40Z</dc:date>
    <item>
      <title>Problem with sprintf and float</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-sprintf-and-float/m-p/133605#M1920</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi,&lt;/DIV&gt;&lt;DIV&gt;I use DEMO9s12xdt512 with CodeWarrior and i have a problem to use sprintf with float.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;In my project i have included the ainsixbf.lib and&amp;nbsp;stdio.h, here my code :&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;***************************&amp;nbsp;&lt;BR /&gt;&amp;nbsp;double toto;&lt;BR /&gt;&amp;nbsp;char chaine[30];&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;toto = 1,2345;&lt;BR /&gt;&amp;nbsp;sprintf(chaine,"bonjour");&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;sprintf(chaine,"%f",toto);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;toto=0.;&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;**************************&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;The first sprintf give the right result but when i want to convert "toto", the string don't have the good result.&lt;/DIV&gt;&lt;DIV&gt;Any idea ?&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Oct 2006 22:30:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-sprintf-and-float/m-p/133605#M1920</guid>
      <dc:creator>cks</dc:creator>
      <dc:date>2006-10-19T22:30:53Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with sprintf and float</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-sprintf-and-float/m-p/133606#M1921</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Maybe it's a typo, but let's confirm...&lt;BR /&gt;&lt;BR /&gt;You have a comma instead of a decimal point in your defintion of toto.&lt;BR /&gt;&lt;BR /&gt;If that's not the issue, what value are you getting?&lt;BR /&gt;&lt;BR /&gt;---Tom&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Oct 2006 22:53:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-sprintf-and-float/m-p/133606#M1921</guid>
      <dc:creator>J2MEJediMaster</dc:creator>
      <dc:date>2006-10-19T22:53:03Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with sprintf and float</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-sprintf-and-float/m-p/133607#M1922</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;Did you specify you want to use floating point arithmetic while creating your project?&lt;/DIV&gt;&lt;DIV&gt;Which is the ANSI library you are linking to&amp;nbsp;the application?&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, 19 Oct 2006 23:29:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-sprintf-and-float/m-p/133607#M1922</guid>
      <dc:creator>CrasyCat</dc:creator>
      <dc:date>2006-10-19T23:29:58Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with sprintf and float</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-sprintf-and-float/m-p/133608#M1923</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;It's ok, i resolve the problem : instead of ainsixbf.lib, i use the ainsixb.lib. Now it works. Thanks.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Oct 2006 14:02:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-sprintf-and-float/m-p/133608#M1923</guid>
      <dc:creator>cks</dc:creator>
      <dc:date>2006-10-20T14:02:12Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with sprintf and float</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-sprintf-and-float/m-p/133609#M1924</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi All,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I tried to use sprintf() and snprintf(), but the file won't compile.&lt;/DIV&gt;&lt;DIV&gt;When I press F1 for help, it says I need a function prototype.&lt;/DIV&gt;&lt;DIV&gt;I've include stdio.h but that still didn't help.&lt;/DIV&gt;&lt;DIV&gt;Have you guys seen this before?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thank you,&lt;/DIV&gt;&lt;DIV&gt;FWFan&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 Oct 2008 08:37:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-sprintf-and-float/m-p/133609#M1924</guid>
      <dc:creator>FWFan</dc:creator>
      <dc:date>2008-10-31T08:37:32Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with sprintf and float</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-sprintf-and-float/m-p/133610#M1925</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;Including stdio.h should allow you to use sprintf without any problem.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;CodeWarrior for HC12 ANSI libraries does not include implementation for snprintf.&lt;/DIV&gt;&lt;DIV&gt;So that is&amp;nbsp;probably the reason you get your message.&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>Mon, 03 Nov 2008 18:51:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-sprintf-and-float/m-p/133610#M1925</guid>
      <dc:creator>CrasyCat</dc:creator>
      <dc:date>2008-11-03T18:51:40Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with sprintf and float</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-sprintf-and-float/m-p/133611#M1926</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi CrasyCat,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I've tried sprintf() also, but that did not work neither.&lt;/DIV&gt;&lt;DIV&gt;I'm using the 8-bit QE128 version of the software.&lt;/DIV&gt;&lt;DIV&gt;I've found a way around to display the 7-segment display.&lt;/DIV&gt;&lt;DIV&gt;But I like to find an answer for this in case I have to&lt;/DIV&gt;&lt;DIV&gt;use it in the future.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thank you for you help.&lt;/DIV&gt;&lt;DIV&gt;FWFan&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Nov 2008 09:20:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-sprintf-and-float/m-p/133611#M1926</guid>
      <dc:creator>FWFan</dc:creator>
      <dc:date>2008-11-04T09:20:49Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with sprintf and float</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-sprintf-and-float/m-p/133612#M1927</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;Do you mean you are using the HCS08QE128?&lt;/DIV&gt;&lt;DIV&gt;In that case you have posted your question in the wrong forum. This forum is around 16-bit MCU (HCS12, HCS12X).&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;For clarity I would recommend that you create a new post in the 8-bit forum or in the CodeWarrior 8-16 bit forum.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Additionally what are you trying to print using sprintf? Floats, int, strings, ....?&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>Tue, 04 Nov 2008 21:56:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-sprintf-and-float/m-p/133612#M1927</guid>
      <dc:creator>CrasyCat</dc:creator>
      <dc:date>2008-11-04T21:56:38Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with sprintf and float</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-sprintf-and-float/m-p/133613#M1928</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi CrasyCat,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Yes, I am using that micro.&amp;nbsp; I was searching in the 8 bit forum but couldn't find the answer.&amp;nbsp; I thought I would &amp;nbsp;try it in the general forum.&amp;nbsp; But somehow ended up in the 16 bit forum.&amp;nbsp; Sorry about that.&amp;nbsp; &amp;nbsp;In any case, I was trying to print my float to string so I can extract the digit to display them on the 7 segment display.&amp;nbsp; Round about way I suppose.&amp;nbsp; Now I just use typecast to get each digit at a time.&amp;nbsp; I don't know if that's the professional way to do it or not.&amp;nbsp; You can see in my attached file.&amp;nbsp; Perhaps you can give me some hints if you have done something like that before.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thank you for understanding.&lt;/DIV&gt;&lt;DIV&gt;FWFan&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Nov 2008 01:14:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-sprintf-and-float/m-p/133613#M1928</guid>
      <dc:creator>FWFan</dc:creator>
      <dc:date>2008-11-05T01:14:31Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with sprintf and float</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-sprintf-and-float/m-p/133614#M1929</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;If you intend to print out floating point variables using sprintf, you need to link with the appropriate ANSI library.&lt;/DIV&gt;&lt;DIV&gt;Which ANSI library file are you linking to your application?&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>Wed, 05 Nov 2008 18:15:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-sprintf-and-float/m-p/133614#M1929</guid>
      <dc:creator>CrasyCat</dc:creator>
      <dc:date>2008-11-05T18:15:27Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with sprintf and float</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-sprintf-and-float/m-p/133615#M1930</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi CrasyCat,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I wasn't aware of linking ANSI library.&lt;/DIV&gt;&lt;DIV&gt;I just included the &amp;lt;stdio.h&amp;gt; in my code.&lt;/DIV&gt;&lt;DIV&gt;I'm quite new to firmware so I was not aware&lt;/DIV&gt;&lt;DIV&gt;I had to do something like that.&lt;/DIV&gt;&lt;DIV&gt;Do you mind giving me a few pointers?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thank you very much.&lt;/DIV&gt;&lt;DIV&gt;FWFan&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Nov 2008 05:15:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-sprintf-and-float/m-p/133615#M1930</guid>
      <dc:creator>FWFan</dc:creator>
      <dc:date>2008-11-06T05:15:55Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with sprintf and float</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-sprintf-and-float/m-p/133616#M1931</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Easiest way is to make a new project through the project wizard and select float upon project creation.&lt;BR /&gt;&lt;BR /&gt;You can also change your current project by taking a backup of it, then toss out ansi**.lib and add ansifs.lib instead. You might also want to set the compiler option -Fd to make doubles 32 bit (IEEE32).&lt;BR /&gt;&lt;BR /&gt;--&lt;BR /&gt;&lt;BR /&gt;However, what you should seriously consider is to toss both sprintf() and float numbers out of the project. Using those on an 8-bit MCU is terrible inefficient in every way, and comes with a number of safety hazards as well.&lt;BR /&gt;&lt;BR /&gt;sprintf() should only be regarded as a debugging/hobbyist function. It is mainly there because CW wants to claim ISO C compliance. Not only is the function inefficient, but va_list functions come with a load of undefined/unspecified behavior. Recognized coding standards such as MISRA-C bans the use of stdio.h in all production code.&lt;BR /&gt;&lt;BR /&gt;The float type in C is usually unnecessary in small, real-time systems. You can usually achieve the same things more effectively using solely integers.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Nov 2008 18:09:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-sprintf-and-float/m-p/133616#M1931</guid>
      <dc:creator>Lundin</dc:creator>
      <dc:date>2008-11-06T18:09:49Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with sprintf and float</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-sprintf-and-float/m-p/133617#M1932</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;To be picky, ANSI C is an irrelevant standard and the compiler should claim to be ISO C compatible and nothing else. "ANSI C" usually refers to the obsolete American standard from 1989. The current ISO C standard ("C99") does include snprintf().&lt;BR /&gt;&lt;BR /&gt;But as we all know, almost no compiler manufacturers implement that standard, but sticks to the old ISO standard from 1990.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Nov 2008 18:20:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-sprintf-and-float/m-p/133617#M1932</guid>
      <dc:creator>Lundin</dc:creator>
      <dc:date>2008-11-06T18:20:18Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with sprintf and float</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-sprintf-and-float/m-p/133618#M1933</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi Lundin,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thank you for your reply.&lt;/DIV&gt;&lt;DIV&gt;I know it's an efficient way to do what I'm trying to do.&lt;/DIV&gt;&lt;DIV&gt;But I've tried and even look up the forum for some hints&lt;/DIV&gt;&lt;DIV&gt;but still couldn't find it.&lt;/DIV&gt;&lt;DIV&gt;Basically, I'm trying to write the decimal numbers up&lt;/DIV&gt;&lt;DIV&gt;to 2 places on my 3 digits 7-segment display.&lt;/DIV&gt;&lt;DIV&gt;I'm trying to find a way to use my lookup table&lt;/DIV&gt;&lt;DIV&gt;for 0-9.&amp;nbsp; It is implemented in the updateDisplay() subroutine.&lt;/DIV&gt;&lt;DIV&gt;Can you spare some hints?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thank you,&lt;/DIV&gt;&lt;DIV&gt;FWFan&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Nov 2008 08:14:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-sprintf-and-float/m-p/133618#M1933</guid>
      <dc:creator>FWFan</dc:creator>
      <dc:date>2008-11-07T08:14:44Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with sprintf and float</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-sprintf-and-float/m-p/133619#M1934</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;First I would suggest not to place the lookup table on the stack.
&amp;gt; char display_digits[10] = {
As it does not change, make it const and static:
&amp;gt; static const char display_digits[10] = {
So it ends up directly in flash and does not have to be created on the stack
which is quite expensive.

Next, I don't see the real need for the float. Currently the code is:

&amp;gt;  byte highVal =...
&amp;gt;  highValDec = (float) highVal * 0.0121;

So instead of computing a float in the 0.0 .. 3.0855 range, I would suggest
to compute an integer in the 0 .. 30855 range and just print a "." inside of the output
&amp;gt;  byte highVal =...
&amp;gt;  unsigned int highValDec =  highVal * 121; // highValDec in 0..30855 range.

Then the computation of the 3 digits need a simple integer division
and a multiplication operation per digit,
a lot cheaper than any floating point operation.

&amp;gt; temp_hi = highValDec / 10000;
&amp;gt; highValDec -= temp_hi * 10000;
&amp;gt; temp_med = highValDec / 1000;
&amp;gt; highValDec -= temp_med * 1000;
&amp;gt; temp_low = highValDec / 100;
&amp;gt; highValDec -= temp_low * 100;

or even:
&amp;gt; highValDec /= 100; // cut off trailing 2 digits.
&amp;gt; temp_hi = highValDec / 100;
&amp;gt; highValDec -= temp_hi * 100;
&amp;gt; temp_med = highValDec / 10;
&amp;gt; highValDec -= temp_med * 10;
&amp;gt; temp_low = highValDec;

Daniel

PS: All code untested, just as idea.



&lt;/PRE&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Nov 2008 09:25:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-sprintf-and-float/m-p/133619#M1934</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2008-11-07T09:25:06Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with sprintf and float</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-sprintf-and-float/m-p/133620#M1935</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi Lundin,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I meant to say "inefficient way".&lt;/DIV&gt;&lt;DIV&gt;My apology.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;FWFan&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Nov 2008 16:04:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-sprintf-and-float/m-p/133620#M1935</guid>
      <dc:creator>FWFan</dc:creator>
      <dc:date>2008-11-07T16:04:38Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with sprintf and float</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-sprintf-and-float/m-p/133621#M1936</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi CompilerGuru,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thank you very much for your help.&lt;/DIV&gt;&lt;DIV&gt;I was trying to find something like that but I couldn't figure it out.&lt;/DIV&gt;&lt;DIV&gt;I was forced to use typcasting in the end.&lt;/DIV&gt;&lt;DIV&gt;But now I can do it a professional way.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Also thanks for your tip on the constant declaration.&lt;/DIV&gt;&lt;DIV&gt;I'm getting some more experience now.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I really appreciate it.&lt;/DIV&gt;&lt;DIV&gt;FWFan&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 08 Nov 2008 03:33:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Problem-with-sprintf-and-float/m-p/133621#M1936</guid>
      <dc:creator>FWFan</dc:creator>
      <dc:date>2008-11-08T03:33:26Z</dc:date>
    </item>
  </channel>
</rss>

