Skip to content

Commit 84e832a

Browse files
author
Thomas G. Lockhart
committed
Use sprintf() to convert float8 to a string during conversion to numeric.
Original code used float8out(), but the resulting exponential notation was not handled (e.g. '3E9' was decoded as '3').
1 parent 54067db commit 84e832a

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/backend/utils/adt/numeric.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* 1998 Jan Wieck
77
*
8-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.11 1999/03/14 16:49:32 momjian Exp $
8+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.12 1999/05/04 15:50:24 thomas Exp $
99
*
1010
* ----------
1111
*/
@@ -1693,7 +1693,7 @@ float8_numeric(float64 val)
16931693
{
16941694
Numeric res;
16951695
NumericVar result;
1696-
char *tmp;
1696+
char buf[512];
16971697

16981698
if (val == NULL)
16991699
return NULL;
@@ -1703,12 +1703,11 @@ float8_numeric(float64 val)
17031703

17041704
init_var(&result);
17051705

1706-
tmp = float8out(val);
1707-
set_var_from_str(tmp, &result);
1706+
sprintf(buf, "%f", *val);
1707+
set_var_from_str(buf, &result);
17081708
res = make_result(&result);
17091709

17101710
free_var(&result);
1711-
pfree(tmp);
17121711

17131712
return res;
17141713
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy