New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix add arithmetic to pass dectest ddAdd.dectest #23
Conversation
decimal64math_test.go
Outdated
@@ -396,6 +382,7 @@ func TestQuoOverflow(t *testing.T) { | |||
require.Equal(NegInfinity64, MustParseDecimal64("-1e384").Quo(MustParseDecimal64("0"))) | |||
require.Equal(QNaN64, Zero64.Quo(Zero64)) | |||
require.Equal(Zero64, Zero64.Quo(MustParseDecimal64("100"))) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still seeing a new blank line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job! One minor naming issue that I'm happy to let slide, since it's an internal function.
decimal64.go
Outdated
@@ -305,3 +444,21 @@ func (d Decimal64) Sign() int { | |||
func (d Decimal64) Signbit() bool { | |||
return d.bits>>63 == 1 | |||
} | |||
|
|||
//size returns the magnitude (number of digits) of a uint64. | |||
func size(n uint64) int { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Needs a better name. Suggestion: numDecimalDigits
(shorter would be better, but I can't think of anything off the top of my head).
decimal64math.go
Outdated
ep.updateMag() | ||
dp.updateMag() | ||
sep := dp.separation(ep) | ||
var ans decParts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move ans
down to just before the if
that fills it.
*Add decParts struct for unpacking decimal * Fix rounding attributes and add rounding iotas and structs except for rounding down and round ceiling * Make struct methods match scales * Add decparts oriented matchscales * Add Nan propagation function, remove SNaN Panics * Fix Cmps, Add more dectest functionality
Passes all halfUp rounding attribute tests in ddAdd.dectest
Does not pass special input tests, weighted Nans and signed Nans