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

FEATURE: [fixedpoint] implement different mul mode #1800

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

c9s
Copy link
Owner

@c9s c9s commented Oct 31, 2024

No description provided.

@bbgokarma-bot
Copy link

Welcome back! @c9s, This pull request may get 268 BBG.

@c9s c9s requested review from kbearXD and gx578007 October 31, 2024 07:17
bigB := big.NewInt(int64(b))
result := new(big.Int).Mul(bigA, bigB)

// 恢復精度 (除以 10^8)
Copy link
Collaborator

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)
Copy link
Collaborator

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
}
Copy link
Collaborator

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
}

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

Successfully merging this pull request may close these issues.

4 participants