Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion decimal.go
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ func (d Decimal) ExpHullAbrham(overallPrecision uint32) (Decimal, error) {
// Return 1 if abs(d) small enough; this also avoids later over/underflow
overflowThreshold2 := New(9, -int32(currentPrecision)-1)
if d.Abs().Cmp(overflowThreshold2) <= 0 {
return Decimal{oneInt, d.exp}, nil
return Decimal{oneInt, 0}, nil
}

// t is the smallest integer >= 0 such that the corresponding abs(d/k) < 1
Expand Down
9 changes: 9 additions & 0 deletions decimal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2953,6 +2953,15 @@ func TestDecimal_ExpHullAbrham(t *testing.T) {
OverallPrecision uint32
ExpectedDec string
}{
{"0.000001", 4, "1"},
{"-0.000001", 4, "1"},
{"0.00000100", 4, "1"},
{"-0.00000100", 4, "1"},
{"0.00009", 4, "1"},
{"0.000000000001", 8, "1"},
{"-0.000000000001", 8, "1"},
{"0.001", 4, "1.001"},
{"-0.001", 4, "0.999"},
{"0", 1, "1"},
{"0.00", 5, "1"},
{"0.5", 5, "1.6487"},
Expand Down