Ejemplo n.º 1
0
func roundFloat64(x exact.Value) exact.Value {
	f, _ := exact.Float64Val(x)
	if !math.IsInf(f, 0) {
		return exact.MakeFloat64(f)
	}
	return nil
}
Ejemplo n.º 2
0
func fitsFloat32(x exact.Value) bool {
	f, _ := exact.Float64Val(x)
	// spec: "In all non-constant conversions involving floating-point
	// or complex values, if the result type cannot represent the value
	// the conversion succeeds but the result value is implementation-
	// dependent."
	//
	// We assume that float32(f) returns an Inf if f is too large for
	// a float32, or if f is an Inf; and that it returns 0 for values
	// with too small a magnitude.
	return !math.IsInf(float64(float32(f)), 0)
}
Ejemplo n.º 3
0
func fitsFloat64(x exact.Value) bool {
	f, _ := exact.Float64Val(x)
	return !math.IsInf(f, 0)
}