func roundFloat64(x exact.Value) exact.Value { f, _ := exact.Float64Val(x) if !math.IsInf(f, 0) { return exact.MakeFloat64(f) } return nil }
// Uint64 returns the numeric value of this constant truncated to fit // an unsigned 64-bit integer. // func (c *Const) Uint64() uint64 { switch x := c.Value; x.Kind() { case exact.Int: if u, ok := exact.Uint64Val(x); ok { return u } return 0 case exact.Float: f, _ := exact.Float64Val(x) return uint64(f) } panic(fmt.Sprintf("unexpected constant value: %T", c.Value)) }
// Complex128 returns the complex value of this constant truncated to // fit a complex128. // func (c *Const) Complex128() complex128 { re, _ := exact.Float64Val(exact.Real(c.Value)) im, _ := exact.Float64Val(exact.Imag(c.Value)) return complex(re, im) }
// Float64 returns the numeric value of this constant truncated to fit // a float64. // func (c *Const) Float64() float64 { f, _ := exact.Float64Val(c.Value) return f }
func fitsFloat64(x exact.Value) bool { f, _ := exact.Float64Val(x) return !math.IsInf(f, 0) }