-
-
Notifications
You must be signed in to change notification settings - Fork 301
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
FEATURE: [fixedpoint] implement different mul mode #1800
base: main
Are you sure you want to change the base?
Conversation
Welcome back! @c9s, This pull request may get 268 BBG. |
bigB := big.NewInt(int64(b)) | ||
result := new(big.Int).Mul(bigA, bigB) | ||
|
||
// 恢復精度 (除以 10^8) |
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.
Please comment in English if possible
@@ -227,11 +229,11 @@ func (v Value) IsZero() bool { | |||
} | |||
|
|||
func Mul(x, y Value) Value { | |||
return NewFromFloat(x.Float64() * y.Float64()) | |||
return mulOp(x, y) |
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.
This might make the mul func slower since there's additional function call. Can you do some bench on the changes to convince people that this works better? Also it's rare that we need to multiply an integer.
result /= scaleFactor | ||
|
||
return result | ||
} |
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.
func multiplyWithInt64(a, b Value) Value {
highA := a / 10000
lowA := a % 10000
highB := b / 10000
lowB := b % 10000
highResult := highA * highB
midResult1 := highA * lowB
midResult2 := lowA * highB
lowResult := lowA * lowB
result := (midResult1 + midResult2) + lowResult/10000
result /= 10000
result += highResult
return result
}
No description provided.