Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 5df20d4

Browse files
Jan WieckJan Wieck
Jan Wieck
authored and
Jan Wieck
committed
Little precision fix for POWER(). I discovered problems with big
exponents. Jan
1 parent 0e9d75c commit 5df20d4

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/backend/utils/adt/numeric.c

Lines changed: 4 additions & 4 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.1 1998/12/30 19:56:29 wieck Exp $
8+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.2 1998/12/30 20:46:05 wieck Exp $
99
*
1010
* ----------
1111
*/
@@ -3371,9 +3371,9 @@ log_var(NumericVar *base, NumericVar *num, NumericVar *result)
33713371

33723372

33733373
/* ----------
3374-
* log_var() -
3374+
* power_var() -
33753375
*
3376-
* Compute the logarithm of x in a given base
3376+
* Raise base to the power of exp
33773377
* ----------
33783378
*/
33793379
static void
@@ -3384,7 +3384,7 @@ power_var(NumericVar *base, NumericVar *exp, NumericVar *result)
33843384
int save_global_rscale;
33853385

33863386
save_global_rscale = global_rscale;
3387-
global_rscale += 8 + MAX(0, exp->weight);
3387+
global_rscale += global_rscale / 3 + 8;
33883388

33893389
init_var(&ln_base);
33903390
init_var(&ln_num);

src/include/utils/numeric.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* 1998 Jan Wieck
77
*
8-
* $Header: /cvsroot/pgsql/src/include/utils/numeric.h,v 1.1 1998/12/30 19:56:35 wieck Exp $
8+
* $Header: /cvsroot/pgsql/src/include/utils/numeric.h,v 1.2 1998/12/30 20:46:06 wieck Exp $
99
*
1010
* ----------
1111
*/
@@ -27,7 +27,7 @@
2727
#define NUMERIC_MAX_DISPLAY_SCALE NUMERIC_MAX_PRECISION
2828
#define NUMERIC_MIN_DISPLAY_SCALE NUMERIC_DEFAULT_SCALE + 4
2929

30-
#define NUMERIC_MAX_RESULT_SCALE (NUMERIC_MAX_PRECISION + 4)
30+
#define NUMERIC_MAX_RESULT_SCALE (NUMERIC_MAX_PRECISION * 2)
3131
#define NUMERIC_MIN_RESULT_SCALE (NUMERIC_DEFAULT_PRECISION + 4)
3232

3333
#define NUMERIC_UNPACKED_DATASIZE (NUMERIC_MAX_PRECISION * 2 + 4)

0 commit comments

Comments
 (0)