libs/libc/stdio/lib_libvsprintf.c: No precision specifier resulted in precision 0 but should be precision 6.

This commit is contained in:
Johannes 2019-02-15 08:42:07 -06:00 committed by Gregory Nutt
parent 8ca1225001
commit 7b9d02d496
2 changed files with 12 additions and 9 deletions

10
TODO
View File

@ -22,7 +22,7 @@ nuttx/:
(18) Network (net/, drivers/net)
(4) USB (drivers/usbdev, drivers/usbhost)
(2) Other drivers (drivers/)
(10) Libraries (libs/libc/, libs/libm/)
(9) Libraries (libs/libc/, libs/libm/)
(12) File system/Generic drivers (fs/, drivers/)
(10) Graphics Subsystem (graphics/)
(1) Build system / Toolchains
@ -1977,14 +1977,6 @@ o Libraries (libs/libc/, libs/libm/)
Status: Open
Priority: Medium (this might important to someone).
Title: FLOATING POINT PRECISION
Description: A fieldwidth and precision is required with the %f format. If %f
is used with no format, than floating numbers will be printed with
a precision of 0 (effectively presented as integers).
Update: Correct, but only with CONFIG_NANO_PRINTF=y.
Status: Open
Priority: Medium (this might important to someone).
Title: LIBM INACCURACIES
Description: "..if you are writing something like robot control or
inertial navigation system for aircraft, I have found

View File

@ -118,6 +118,10 @@
# define FMT_PREV src-- /* Backup to the previous character */
#endif
/* Default precision to use with %f format if no precision is specified. */
#define FLOAT_PRECISION_DEFAULT 6
/****************************************************************************
* Private Type Declarations
****************************************************************************/
@ -1555,6 +1559,13 @@ int lib_vsprintf(FAR struct lib_outstream_s *obj, FAR const IPTR char *src,
double dblval = va_arg(ap, double);
int dblsize;
/* Set to default precision if none specified */
if (!IS_HASDOT(flags) && trunc == 0)
{
trunc = FLOAT_PRECISION_DEFAULT;
}
/* Get the width of the output */
dblsize = getdblsize(FMT_CHAR, trunc, flags, dblval);