shopspring / decimal

Arbitrary-precision fixed-point decimal numbers in Go
Other
6.41k stars 623 forks source link

Why decimal.NewFromFloat(1000) Exponent is 3, and decimal.NewFromInt(1000) Exponent is 0 #374

Open kkbblzq opened 4 months ago

kkbblzq commented 4 months ago

code

floatVal := decimal.NewFromFloat(1000)
fmt.Println("Exponent: ", floatVal.Exponent())

intVal := decimal.NewFromInt(1000)
fmt.Println("Exponent: ", intVal.Exponent())

output

Exponent:  3
Exponent:  0