)
const (
- // TODO(gri) consider increasing Mpprec to 512 or perhaps 1024
- // (this would permit enabling additional tests).
- Mpprec = 16 * 29 // == 464, to match original value
- Mpdebug = 0
+ // Maximum size in bits for Mpints before signalling
+ // overflow and also mantissa precision for Mpflts.
+ Mpprec = 512
+ // Turn on for constant arithmetic debugging output.
+ Mpdebug = false
)
// Mpint represents an integer constant.
return 0
}
- // TODO(gri) reduce the value of delta - currently
- // we use the size of a mp-word of the old implementation
- // for approximately similar behavior.
- const delta = 29 // a reasonably small number of bits > 0
+ const delta = 16 // a reasonably small number of bits > 0
var t big.Float
t.SetPrec(Mpprec - delta)
}
func mpaddfltflt(a *Mpflt, b *Mpflt) {
- if Mpdebug != 0 {
+ if Mpdebug {
fmt.Printf("\n%v + %v", Fconv(a, 0), Fconv(b, 0))
}
a.Val.Add(&a.Val, &b.Val)
- if Mpdebug != 0 {
+ if Mpdebug {
fmt.Printf(" = %v\n\n", Fconv(a, 0))
}
}
}
func mpsubfltflt(a *Mpflt, b *Mpflt) {
- if Mpdebug != 0 {
+ if Mpdebug {
fmt.Printf("\n%v - %v", Fconv(a, 0), Fconv(b, 0))
}
a.Val.Sub(&a.Val, &b.Val)
- if Mpdebug != 0 {
+ if Mpdebug {
fmt.Printf(" = %v\n\n", Fconv(a, 0))
}
}
func mpmulfltflt(a *Mpflt, b *Mpflt) {
- if Mpdebug != 0 {
+ if Mpdebug {
fmt.Printf("%v\n * %v\n", Fconv(a, 0), Fconv(b, 0))
}
a.Val.Mul(&a.Val, &b.Val)
- if Mpdebug != 0 {
+ if Mpdebug {
fmt.Printf(" = %v\n\n", Fconv(a, 0))
}
}
}
func mpdivfltflt(a *Mpflt, b *Mpflt) {
- if Mpdebug != 0 {
+ if Mpdebug {
fmt.Printf("%v\n / %v\n", Fconv(a, 0), Fconv(b, 0))
}
a.Val.Quo(&a.Val, &b.Val)
- if Mpdebug != 0 {
+ if Mpdebug {
fmt.Printf(" = %v\n\n", Fconv(a, 0))
}
}
}
func Mpmovecflt(a *Mpflt, c float64) {
- if Mpdebug != 0 {
+ if Mpdebug {
fmt.Printf("\nconst %g", c)
}
a.Val.SetFloat64(c)
- if Mpdebug != 0 {
+ if Mpdebug {
fmt.Printf(" = %v\n", Fconv(a, 0))
}
}