Skip to content

Commit

Permalink
Integers get "x y ^" for x^y, pow becomes f^ for consistency.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pete Elmore committed Oct 28, 2009
1 parent 06bf113 commit 6d9ebf2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
16 changes: 15 additions & 1 deletion pez.c
Original file line number Diff line number Diff line change
Expand Up @@ -1755,6 +1755,19 @@ prim P_log(pez_instance *p)
Mathfunc(log);
}

prim P_ipow(pez_instance *p)
{
pez_stackitem i, n;
Sl(2);

// A somewhat naive implementation:
n = S1;
for(i = 0; i < S0; i++)
S1 *= n;

Pop;
}

prim P_pow(pez_instance *p)
{ /* X ^ Y */
Sl(2 * Realsize);
Expand Down Expand Up @@ -3807,7 +3820,8 @@ static struct primfcn primt[] = {
{"0COS", P_cos},
{"0EXP", P_exp},
{"0LOG", P_log},
{"0POW", P_pow},
{"0^", P_ipow},
{"0F^", P_pow},
{"0SIN", P_sin},
{"0SQRT", P_sqrt},
{"0TAN", P_tan},
Expand Down
8 changes: 4 additions & 4 deletions regress.pez
Original file line number Diff line number Diff line change
Expand Up @@ -679,10 +679,10 @@ variable k
1.0 e f/ log -1.0 fok?

"POW" tests:
2.0 4.0 pow 16.0 fok?
2.0 -1.0 pow 0.5 fok?
8.0 1.0 3.0 f/ pow 2.0 fok?
e pi log pow pi fok?
2.0 4.0 f^ 16.0 fok?
2.0 -1.0 f^ 0.5 fok?
8.0 1.0 3.0 f/ f^ 2.0 fok?
e pi log f^ pi fok?

"SIN" tests:
0.0 sin 0.0 fok?
Expand Down

0 comments on commit 6d9ebf2

Please sign in to comment.