Skip to content

Commit

Permalink
add hugenum regression
Browse files Browse the repository at this point in the history
  • Loading branch information
rsoeldner authored and jmcardon committed Oct 14, 2024
1 parent 7a0bca2 commit 95e5b99
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions pact-tests/pact-tests/ops.repl
Original file line number Diff line number Diff line change
Expand Up @@ -419,12 +419,12 @@
(expect "^ integer decimal" 9.0 (^ 81 0.5))
(expect "^ decimal integer" 15.625 (^ 2.5 3))

; (expect
; "hugenum regression"
; 12020.67042599064370733685791492462158203125
; (^
; 15.034465284692086701747761395233132973944448512421004399685858401206740385711739229018307610943234609057822959334669087436253689423614206061665462283698768757790600552385430913941421707844383369633809803959413869974997415115322843838226312287673293352959835
; 3.466120406090666777582519661568003549307295836842780244500133445635634490670936927006970368136648330889718447039413255137656971927890831071689768359173260960739254160211017410322799793419223796996260056081828170546988461285168124170297427792046640116184356))
(expect
"hugenum regression"
12020.67042599064370733685791492462158203125
(^
15.034465284692086701747761395233132973944448512421004399685858401206740385711739229018307610943234609057822959334669087436253689423614206061665462283698768757790600552385430913941421707844383369633809803959413869974997415115322843838226312287673293352959835
3.466120406090666777582519661568003549307295836842780244500133445635634490670936927006970368136648330889718447039413255137656971927890831071689768359173260960739254160211017410322799793419223796996260056081828170546988461285168124170297427792046640116184356))

"===== truncating"
(expect "round" 100 (round 100.1))
Expand Down
6 changes: 3 additions & 3 deletions pact/Pact/Core/IR/Eval/CEK/CoreBuiltin.hs
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,12 @@ rawPow info b cont handler _env = \case
decPow i (Decimal 0 i')
args -> argsError info b args
where
decPow l r = do
when (l == 0 && r < 0) $
decPow base pow = do
when (base == 0 && pow < 0) $
throwExecutionError info (FloatingPointError "zero to a negative power is undefined")
let integralPart = floor pow
chargeGasArgs info $ GIntegerOpCost PrimOpPow (decimalMantissa base) integralPart
result <- guardNanOrInf info $ MPFR.mpfr_pow l r
result <- guardNanOrInf info $ MPFR.mpfr_pow base pow
returnCEKValue cont handler (VLiteral (LDecimal result))

rawLogBase :: forall e b i. (IsBuiltin b) => NativeFunction e b i
Expand Down
6 changes: 3 additions & 3 deletions pact/Pact/Core/IR/Eval/Direct/CoreBuiltin.hs
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,12 @@ rawPow info b _env = \case
decPow i (Decimal 0 i')
args -> argsError info b args
where
decPow l r = do
when (l == 0 && r < 0) $
decPow base pow = do
when (base == 0 && pow < 0) $
throwExecutionError info (FloatingPointError "zero to a negative power is undefined")
let integralPart = floor pow
chargeGasArgs info $ GIntegerOpCost PrimOpPow (decimalMantissa base) integralPart
result <- guardNanOrInf info $ MPFR.mpfr_pow l r
result <- guardNanOrInf info $ MPFR.mpfr_pow base pow
return (VLiteral (LDecimal (result)))

rawLogBase :: forall e b i. (IsBuiltin b) => NativeFunction e b i
Expand Down

0 comments on commit 95e5b99

Please sign in to comment.