cockroachdb / cockroachdb/apd

Context.Rem fails for Rem(100E100, 10)

Open
#134 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
Go
Stars
805
Forks
48
PR merge metrics
No merged PRs in 30d

Description

I attempted to run the following test:

```golang
func TestRem(t *testing.T) {
a := apd.New(100, 100)
b := apd.New(10, 1)
var rem apd.Decimal
_, err := apd.BaseContext.Rem(&rem, a, b)
if err != nil {
t.Fatal(err)
}

if !rem.IsZero() {
t.Fatal("expected zero")
}
}
```

I would expect this test to pass, but it fails:

```
=== RUN TestRem
rem_test.go:72: division impossible
--- FAIL: TestRem (0.00s)

FAIL
```

apd.BaseContext.Rem returns `division impossible`, which (I believe) is an incorrect result in this case.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with Context.Rem and reproduce the failing case from the issue's TestRem example, using rem_test.go around line 72 as the test location mentioned by the failure. Trace why Rem(100E100, 10) returns division impossible; done means the case completes without an error and produces a zero remainder.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.