Skip to content
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 to speed up math operations by more than 50% #136

Closed
kempeng opened this issue Feb 19, 2019 · 2 comments
Closed

Fix to speed up math operations by more than 50% #136

kempeng opened this issue Feb 19, 2019 · 2 comments

Comments

@kempeng
Copy link

kempeng commented Feb 19, 2019

see issue #128:
fix for decimal.go/rescale()

// NOTE(vadim): must convert exps to int64 before - to prevent overflow
	diff := abs64(int64(exp) - int64(d.exp))
// NEW TEST, avoids unnecessary rescaling
	if diff == 0 {
		return d
	}
// END
	value := new(big.Int).Set(d.value)
	expScale := new(big.Int).Exp(tenInt, big.NewInt(int64(diff)), nil)
@mwoss
Copy link
Member

mwoss commented Dec 2, 2019

Thanks for pointing this out @kempeng. I will look closer on this and continue the discussion in mentioned issue #128

@mwoss
Copy link
Member

mwoss commented Feb 2, 2020

Closed by #160

@mwoss mwoss closed this as completed Feb 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants