Skip to content

Commit

Permalink
Add InexactFloat64 method (#205)
Browse files Browse the repository at this point in the history
* Add func (d Decimal) MustFloat64()
* renames MustFloat64 to InexactFloat64
  • Loading branch information
felipeneuwald authored Mar 29, 2021
1 parent f77bb07 commit 5016615
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions decimal.go
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,13 @@ func (d Decimal) Float64() (f float64, exact bool) {
return d.Rat().Float64()
}

// InexactFloat64 returns the nearest float64 value for d.
// It doesn't indicate if the returned value represents d exactly.
func (d Decimal) InexactFloat64() float64 {
f, _ := d.Float64()
return f
}

// String returns the string representation of the decimal
// with the fixed point.
//
Expand Down

0 comments on commit 5016615

Please sign in to comment.