Skip to content

Conversation

@c9s
Copy link
Owner

@c9s c9s commented Oct 31, 2024

No description provided.

@c9s c9s requested review from narumiruna and zenixls2 October 31, 2024 07:16
@bbgokarma-bot
Copy link

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

@c9s c9s requested review from gx578007 and kbearXD 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


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
Contributor

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.

5 participants