MCPcopy Create free account
hub / github.com/cockroachdb/apd / SetFloat64

Method SetFloat64

decimal.go:249–253  ·  view source on GitHub ↗

SetFloat64 sets d's Coefficient and Exponent to x and returns d. d will hold the exact value of f.

(f float64)

Source from the content-addressed store, hash-verified

247// SetFloat64 sets d's Coefficient and Exponent to x and returns d. d will
248// hold the exact value of f.
249func (d *Decimal) SetFloat64(f float64) (*Decimal, error) {
250 var buf [32]byte // Avoid most of the allocations in strconv.
251 _, _, err := d.SetString(string(strconv.AppendFloat(buf[:0], f, 'E', -1, 64)))
252 return d, err
253}
254
255// Int64 returns the int64 representation of x. If x cannot be represented in an
256// int64, an error is returned.

Callers 7

BenchmarkDecimalSetFloatFunction · 0.95
LnMethod · 0.95
ScanMethod · 0.95
BenchmarkDecimalStringFunction · 0.80
TestFloat64Function · 0.80
TestCeilFunction · 0.80
TestFloorFunction · 0.80

Calls 1

SetStringMethod · 0.95

Tested by 5

BenchmarkDecimalSetFloatFunction · 0.76
BenchmarkDecimalStringFunction · 0.64
TestFloat64Function · 0.64
TestCeilFunction · 0.64
TestFloorFunction · 0.64