Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
revert var name change
  • Loading branch information
ceyonur committed Sep 24, 2025
commit 9efd27a86c45b4d5875dbd89a79b55ea0940e207
4 changes: 2 additions & 2 deletions utils/math/exponential.go
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add tests for this new code?

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/holiman/uint256"
)

var maxUint64 = new(uint256.Int).SetUint64(math.MaxUint64)
var max256Uint64 = new(uint256.Int).SetUint64(math.MaxUint64)

// CalculateExponential returns the approximate exponential result given the factor, the
// numerator, and the denominator.
Expand Down Expand Up @@ -60,7 +60,7 @@ func CalculateExponential(
numeratorAccum.SetUint64(factor) // range is [0, MaxUint64]
numeratorAccum.Mul(&numeratorAccum, &denom) // range is [0, MaxUint128]

maxOutput.Mul(&denom, maxUint64) // range is [0, MaxUint128]
maxOutput.Mul(&denom, max256Uint64) // range is [0, MaxUint128]
for numeratorAccum.Sign() > 0 {
output.Add(&output, &numeratorAccum) // range is [0, MaxUint192+MaxUint128]
if output.Cmp(&maxOutput) >= 0 {
Expand Down