Skip to content

Commit 4c47b07

Browse files
author
ffranr
authored
Merge pull request #1137 from lightninglabs/fixed-point-doc-mul-div
rfqmath: clarify scale requirement in FixedPoint Mul and Div docs
2 parents 3b92c82 + 70cbe2a commit 4c47b07

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)