<?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 Ouch sprintf is 6000+ bytes to get Float to LCD in 8-bit Microcontrollers</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Ouch-sprintf-is-6000-bytes-to-get-Float-to-LCD/m-p/166764#M10698</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need to take a floating point number from -9999. to -.0001 to&amp;nbsp;0 to .0001&amp;nbsp;to 9999.&amp;nbsp; and display it on an&amp;nbsp; 7 segment 4 digit&amp;nbsp;LCD.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I had planned to use sprintf to take the float (or double)&amp;nbsp; and convert it to an ascii string stored in a buffer. Then the buffer could picked apart to get the sign, digits, and proper decimal point. location.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But the freescale implementation&amp;nbsp;of sprintf is over 6000 bytes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have any suggestions for code which does not occupy as much space?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 14 Sep 2011 04:01:10 GMT</pubDate>
    <dc:creator>PG1</dc:creator>
    <dc:date>2011-09-14T04:01:10Z</dc:date>
    <item>
      <title>Ouch sprintf is 6000+ bytes to get Float to LCD</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Ouch-sprintf-is-6000-bytes-to-get-Float-to-LCD/m-p/166764#M10698</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need to take a floating point number from -9999. to -.0001 to&amp;nbsp;0 to .0001&amp;nbsp;to 9999.&amp;nbsp; and display it on an&amp;nbsp; 7 segment 4 digit&amp;nbsp;LCD.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I had planned to use sprintf to take the float (or double)&amp;nbsp; and convert it to an ascii string stored in a buffer. Then the buffer could picked apart to get the sign, digits, and proper decimal point. location.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But the freescale implementation&amp;nbsp;of sprintf is over 6000 bytes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have any suggestions for code which does not occupy as much space?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Sep 2011 04:01:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Ouch-sprintf-is-6000-bytes-to-get-Float-to-LCD/m-p/166764#M10698</guid>
      <dc:creator>PG1</dc:creator>
      <dc:date>2011-09-14T04:01:10Z</dc:date>
    </item>
    <item>
      <title>Re: Ouch sprintf is 6000+ bytes to get Float to LCD</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Ouch-sprintf-is-6000-bytes-to-get-Float-to-LCD/m-p/166765#M10699</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One possible approach is to convert the float value to a fixed point value with 16-bit integer and fractional parts.&amp;nbsp; Each part can then be separately converted to ASCII decimal characters for the display.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;  float x = 455.1234;  int integer;    // Integer part  word frac;      // Fractional part    integer = (int)x;  frac = (int)((long)(x * 10000) - integer * 10000);  // Range 0 - 9999&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When displaying the integer part, you might normally suppress leading zeros.&amp;nbsp; However, the fractional part would require leading zeros to be present.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:14:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Ouch-sprintf-is-6000-bytes-to-get-Float-to-LCD/m-p/166765#M10699</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2020-10-29T09:14:15Z</dc:date>
    </item>
  </channel>
</rss>

