Re: lcdprint with dtostrf

James Hamilton <[email protected]> Sat, 15 Jul 2017 21:10:10 -0400
Newsgroups gmane.comp.hardware.avr.gcc
Message-ID <CAFDeXgzTqZZpfaXKZ2znpP6XYifyhXfkh7DiGkWOH81FM0r38Q@mail.gmail.com>
​Ismail: could you please post more of your code, especially the definition
of buffer?  Also, do you have the word "float" in your call to stostrf, or
were you just letting us know that "number" is a float?  The type of
"number" should not be in the call to dtostrf().  From some forum posts, it
looks like there may be a bug with dtostrf() when using a float instead of
a double.  Can you try using a double for "number" instead of a float?

All: I haven't used dtostrf() before, but based on my cursory glance at
it's definition, it seems unsafe (in the snprintf vs sprintf sense).  Am I
missing something that would prevent a buffer overflow when using
dtostrf(), or is assumed that the caller knows how to test the length of
the string the double will produce before calling dtostrf()?  Is there a
version of dtostrf() that accepts a max length argument (other than
snprintf)?

73,

~James

On Sat, Jul 15, 2017 at 3:47 PM,
​​
Ismail <[email protected]> wrote:

> hi, i am having difficulty in sending a floating point number to lcd.
>
> i ham using
>
> dtostrf(float number, 5,2, buffer);
> lcdprint(buffer);
>
> but invain
>

_______________________________________________
AVR-GCC-list mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/avr-gcc-list