Skip to content

Commit

Permalink
math.functions: change { float integer } ^ to use fpow
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjbq7 committed Feb 7, 2024
1 parent 18fe08f commit c4b5967
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions basis/math/functions/functions.factor
Expand Up @@ -43,11 +43,11 @@ M: bignum ^n
M: ratio ^n
[ >fraction ] dip '[ _ ^n ] bi@ / ;

M: float ^n (^n) ;
M: float ^n [ >float fpow ] unless-zero ;

M: complex ^n (^n) ;

: integer^ ( x y -- z )
: ^integer ( x y -- z )
dup 0 >= [ ^n ] [ [ recip ] dip neg ^n ] if ; inline

PRIVATE>
Expand Down Expand Up @@ -99,7 +99,7 @@ PRIVATE>
: ^ ( x y -- x^y )
{
{ [ over zero? ] [ 0^ ] }
{ [ dup integer? ] [ integer^ ] }
{ [ dup integer? ] [ ^integer ] }
{ [ 2dup real^? ] [ [ >float ] bi@ fpow ] }
[ ^complex ]
} cond ; inline
Expand Down

0 comments on commit c4b5967

Please sign in to comment.