stdlib function dtostrf(...)

I can find sldlib.h in my arduino IDE installation folder and I can find the function definition.

But where is this defined: DTOSTRE_UPPERCASE?

If I try to use it I get a compile error.

boylesg:
I can find sldlib.h in my arduino IDE installation folder and I can find the function definition.

But where is this defined: DTOSTRE_UPPERCASE?

If I try to use it I get a compile error.

Have you tried re-install Arduino IDE with newest version and recompile the sketch. I think the problem is your IDE as I using dtostrf function normally.

If not successfully after reinstall. Please give a little more about the error.

Regards,

I had to alter my post. I missed the 'E' at first.
Are you sure you want "DTOSTRE_UPPERCASE" and not "DTOSTR_UPPERCASE"?

boylesg:
I can find sldlib.h in my arduino IDE installation folder and I can find the function definition.

But where is this defined: DTOSTRE_UPPERCASE?

If I try to use it I get a compile error.

I found this define on line 612 of "stdlib.h":-

/** \ingroup avr_stdlib
    Bit value that can be passed in \c flags to dtostre(). */
#define DTOSTR_UPPERCASE   0x04        /* put 'E' rather 'e' */

And the extra 'E' would explain the compile error.

There’s a documentation error: the constants begin with DTOSTR_, but the documentation says DTOSTRE_.

/** \ingroup avr_stdlib
    Bit value that can be passed in \c flags to dtostre(). */
#define DTOSTR_ALWAYS_SIGN 0x01        /* put '+' or ' ' for positives */
/** \ingroup avr_stdlib
    Bit value that can be passed in \c flags to dtostre(). */
#define DTOSTR_PLUS_SIGN   0x02        /* put '+' rather than ' ' */
/** \ingroup avr_stdlib
    Bit value that can be passed in \c flags to dtostre(). */
#define DTOSTR_UPPERCASE   0x04        /* put 'E' rather 'e' */

#ifndef __ASSEMBLER__

/**
   \ingroup avr_stdlib
   The dtostre() function converts the double value passed in \c val into
   an ASCII representation that will be stored under \c s.  The caller
   is responsible for providing sufficient storage in \c s.

   Conversion is done in the format \c "[-]d.ddde<B1>dd" where there is
   one digit before the decimal-point character and the number of
   digits after it is equal to the precision \c prec; if the precision
   is zero, no decimal-point character appears.  If \c flags has the
   DTOSTRE_UPPERCASE bit set, the letter \c 'E' (rather than \c 'e' ) will be
   used to introduce the exponent.  The exponent always contains two
   digits; if the value is zero, the exponent is \c "00".

   If \c flags has the DTOSTRE_ALWAYS_SIGN bit set, a space character
   will be placed into the leading position for positive numbers.

   If \c flags has the DTOSTRE_PLUS_SIGN bit set, a plus sign will be
   used instead of a space character in this case.

   The dtostre() function returns the pointer to the converted string \c s.
*/
extern char *dtostre(double __val, char *__s, unsigned char __prec,
                     unsigned char __flags);

oqibidipo:
There’s a documentation error: the constants begin with DTOSTR_, but the documentation says DTOSTRE_.

/** \ingroup avr_stdlib

Bit value that can be passed in \c flags to dtostre(). /
#define DTOSTR_ALWAYS_SIGN 0x01        /
put ‘+’ or ’ ’ for positives /
/
* \ingroup avr_stdlib
    Bit value that can be passed in \c flags to dtostre(). /
#define DTOSTR_PLUS_SIGN  0x02        /
put ‘+’ rather than ’ ’ /
/
* \ingroup avr_stdlib
    Bit value that can be passed in \c flags to dtostre(). /
#define DTOSTR_UPPERCASE  0x04        /
put ‘E’ rather ‘e’ */

#ifndef ASSEMBLER

/**
  \ingroup avr_stdlib
  The dtostre() function converts the double value passed in \c val into
  an ASCII representation that will be stored under \c s.  The caller
  is responsible for providing sufficient storage in \c s.

Conversion is done in the format \c “[-]d.dddedd” where there is
  one digit before the decimal-point character and the number of
  digits after it is equal to the precision \c prec; if the precision
  is zero, no decimal-point character appears.  If \c flags has the
  DTOSTRE_UPPERCASE bit set, the letter \c ‘E’ (rather than \c ‘e’ ) will be
  used to introduce the exponent.  The exponent always contains two
  digits; if the value is zero, the exponent is \c “00”.

If \c flags has the DTOSTRE_ALWAYS_SIGN bit set, a space character
  will be placed into the leading position for positive numbers.

If \c flags has the DTOSTRE_PLUS_SIGN bit set, a plus sign will be
  used instead of a space character in this case.

The dtostre() function returns the pointer to the converted string \c s.
*/
extern char *dtostre(double __val, char *__s, unsigned char __prec,
                    unsigned char __flags);

Ah, that’s where the ‘E’ came from. :slight_smile:

I have submitted bug #49020.

oqibidipo:
I have submitted bug #49020.

Excellent. It’s good to get these things fixed when we see them. :slight_smile:
It avoids going through the whole process over and over when others are misled by the documentation.