Skip to content

Commit 70cbe2a

Browse files
committed
rfqmath: clarify scale requirement in FixedPoint Mul and Div docs
This commit updates the documentation for `FixedPoint.Mul` and `FixedPoint.Div` to specify that these methods cannot be used with arguments having different scale values from the target fixed-point. This clarification helps prevent misuse of these methods.
1 parent 3b92c82 commit 70cbe2a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

rfqmath/fixed_point.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ func (f FixedPoint[T]) ToFloat64() float64 {
7474

7575
// Mul returns a new FixedPoint that is the result of multiplying the existing
7676
// int by the passed one.
77+
//
78+
// NOTE: This function assumes that the scales of the two FixedPoint values are
79+
// identical. If the scales differ, the result may be incorrect.
7780
func (f FixedPoint[T]) Mul(other FixedPoint[T]) FixedPoint[T] {
7881
multiplier := NewInt[T]().FromFloat(math.Pow10(int(f.Scale)))
7982

@@ -87,6 +90,9 @@ func (f FixedPoint[T]) Mul(other FixedPoint[T]) FixedPoint[T] {
8790

8891
// Div returns a new FixedPoint that is the result of dividing the existing int
8992
// by the passed one.
93+
//
94+
// NOTE: This function assumes that the scales of the two FixedPoint values are
95+
// identical. If the scales differ, the result may be incorrect.
9096
func (f FixedPoint[T]) Div(other FixedPoint[T]) FixedPoint[T] {
9197
multiplier := NewInt[T]().FromFloat(math.Pow10(int(f.Scale)))
9298

0 commit comments

Comments
 (0)