golang decimal only retains two decimal places

package main
 
import (
	"fmt"
	"github.com/shopspring/decimal"
)
 
func main() {
 
	var dd decimal.Decimal
	
	f := 12.435235235
    
	
	dd = decimal.NewFromFloatWithExponent(f, -2)
 
	cc := dd.Round(2)
 
	fmt.Println(dd)
 
	fmt.Println(cc)
}

Leave a Reply

Your email address will not be published. Required fields are marked *

en_USEnglish