Skip to content
Snippets Groups Projects
Commit 968efe9c authored by Henrik (Grubba) Grubbström's avatar Henrik (Grubba) Grubbström
Browse files

Fixed bug in pow().

Rev: src/modules/math/math.c:1.11
parent 7f962820
No related branches found
No related tags found
No related merge requests found
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include "module_support.h" #include "module_support.h"
#include "operators.h" #include "operators.h"
RCSID("$Id: math.c,v 1.10 1998/03/28 13:56:48 grubba Exp $"); RCSID("$Id: math.c,v 1.11 1998/06/07 21:20:15 grubba Exp $");
#ifndef M_PI #ifndef M_PI
#define M_PI 3.1415926535897932384626433832795080 #define M_PI 3.1415926535897932384626433832795080
...@@ -23,6 +23,28 @@ RCSID("$Id: math.c,v 1.10 1998/03/28 13:56:48 grubba Exp $"); ...@@ -23,6 +23,28 @@ RCSID("$Id: math.c,v 1.10 1998/03/28 13:56:48 grubba Exp $");
int matherr(struct exception *exc) int matherr(struct exception *exc)
{ {
#ifdef HUGE_VAL
if (exc) {
switch(exc->type) {
case OVERFLOW:
exc->retval = HUGE_VAL;
return 1; /* No error */
case UNDERFLOW:
exc->retval = 0.0;
return 1; /* No error */
#ifdef TLOSS
case TLOSS:
return 1; /* No error */
#endif /* TLOSS */
#ifdef PLOSS
case PLOSS:
return 1; /* No error */
#endif /* PLOSS */
default:
return 0; /* Error */
}
}
#endif /* HUGE_VAL */
return 1; /* No error */ return 1; /* No error */
} }
...@@ -131,12 +153,13 @@ void f_exp(INT32 args) ...@@ -131,12 +153,13 @@ void f_exp(INT32 args)
void f_pow(INT32 args) void f_pow(INT32 args)
{ {
float tmp;
if(args<2) error("Too few arguments to pow()\n"); if(args<2) error("Too few arguments to pow()\n");
if(sp[-args].type!=T_FLOAT) error("Bad argument 1 to pow()\n"); if(sp[-args].type!=T_FLOAT) error("Bad argument 1 to pow()\n");
if(sp[1-args].type!=T_FLOAT) error("Bad argument 2 to pow()\n"); if(sp[1-args].type!=T_FLOAT) error("Bad argument 2 to pow()\n");
sp[-args].u.float_number=pow(sp[-args].u.float_number, tmp = pow(sp[-args].u.float_number, sp[1-args].u.float_number);
sp[1-args].u.float_number); sp[-args].u.float_number = tmp;
sp--; pop_n_elems(args-1);
} }
void f_floor(INT32 args) void f_floor(INT32 args)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment