aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/interfaces/ecpg/pgtypeslib/numeric.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/interfaces/ecpg/pgtypeslib/numeric.c b/src/interfaces/ecpg/pgtypeslib/numeric.c
index 0504f3cac8a..d061616787e 100644
--- a/src/interfaces/ecpg/pgtypeslib/numeric.c
+++ b/src/interfaces/ecpg/pgtypeslib/numeric.c
@@ -2,6 +2,7 @@
#include "postgres_fe.h"
#include <ctype.h>
+#include <float.h>
#include <limits.h>
#include "extern.h"
@@ -1497,11 +1498,11 @@ PGTYPESnumeric_copy(numeric *src, numeric *dst)
int
PGTYPESnumeric_from_double(double d, numeric *dst)
{
- char buffer[100];
+ char buffer[DBL_DIG + 100];
numeric *tmp;
int i;
- if (sprintf(buffer, "%f", d) == 0)
+ if (sprintf(buffer, "%.*g", DBL_DIG, d) <= 0)
return -1;
if ((tmp = PGTYPESnumeric_from_asc(buffer, NULL)) == NULL)