Commit 75250a9f authored by Robert Griesemer's avatar Robert Griesemer

cmd/compile/internal/gc: simplify mpgetflt (remove switch and indirection)

Change-Id: I6ae3534defdae9367e1b856dbb8e846c3263a758
Reviewed-on: https://go-review.googlesource.com/10358Reviewed-by: 's avatarAlan Donovan <adonovan@google.com>
parent bd7c1f1f
......@@ -105,17 +105,8 @@ func mpcmpfltc(b *Mpflt, c float64) int {
return mpcmpfltflt(b, &a)
}
func mpgetfltN(a *Mpflt, prec int, bias int) float64 {
var x float64
switch prec {
case 53:
x, _ = a.Val.Float64()
case 24:
x32, _ := a.Val.Float32()
x = float64(x32)
default:
panic("unreachable")
}
func mpgetflt(a *Mpflt) float64 {
x, _ := a.Val.Float64()
// check for overflow
if math.IsInf(x, 0) && nsavederrors+nerrors == 0 {
......@@ -125,12 +116,16 @@ func mpgetfltN(a *Mpflt, prec int, bias int) float64 {
return x
}
func mpgetflt(a *Mpflt) float64 {
return mpgetfltN(a, 53, -1023)
}
func mpgetflt32(a *Mpflt) float64 {
return mpgetfltN(a, 24, -127)
x32, _ := a.Val.Float32()
x := float64(x32)
// check for overflow
if math.IsInf(x, 0) && nsavederrors+nerrors == 0 {
Yyerror("mpgetflt32 ovf")
}
return x
}
func Mpmovecflt(a *Mpflt, c float64) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment