Split of small negative values doesn't work properly
arzonus opened this issue · 1 comments
arzonus commented
I found that a small negative amount will be split wrongly.
Example
package main
import (
"fmt"
"github.com/Rhymond/go-money"
)
func main() {
var val = money.New(-2, "EUR")
parts, err := val.Split(3)
if err != nil {
fmt.Println(err)
}
for _, part := range parts {
fmt.Println(part.Display())
}
}
Expected output
-€0.01
-€0.01
-€0.00
Actual output
€0.01
€0.01
€0.00
It seems that if a money value is less than the number of split parts it returns a wrong sign because 0.04/3 returns 0.02,0.01,0.01.
Rhymond commented
Thanks, Great find! The issue is fixed and released in v1.0.6 release