func (d *Dec) Mul(x, y *Dec) *Dec {
	d.scale = x.scale + y.scale
	d.coef.Mul(&x.coef, &y.coef)
	return d
}
Mul sets d to the product x*y and returns d.
The scale of d is the sum of the scales of the two operands.
package decimal
import (
	"bytes"
	"database/sql/driver"
	"errors"
	"io"
	"math"
	"strconv"
	"strings"
)
type Dec struct {
	coef  Int128
	scale uint8
}
func New(n int64) *Dec {
	d := new(Dec)
	d.SetInt64(n)
	return d
}
var decOne = New(1)
func (d *Dec) Set(x *Dec) *Dec {
	if d != x {
		d.coef = x.coef
		d.scale = x.scale
	}
	return d
}
func (d *Dec) SetInt128(x *Int128) *Dec {
	d.scale = 0
	d.coef = *x
	return d
}
func (d Dec) Sign() int {
	return d.coef.Sign()
}
func exp10(scale uint8) *Int128 {
	switch scale {
	case 0:
		return intOne
	case 1:
		return intTen
	case 2:
		return &Int128{100, 0}
	case 3:
		return &Int128{1000, 0}
	case 4:
		return &Int128{10000, 0}
	case 5:
		return &Int128{100000, 0}
	case 6:
		return &Int128{1000000, 0}
	case 7:
		return &Int128{10000000, 0}
	case 8:
		return &Int128{100000000, 0}
	}
	var z Int128
	z.Power(intTen, uint(scale))
	return &z
}
func (d *Dec) rescale(scale uint8) *Dec {
	if scale == d.scale {
		return d
	} else if scale < d.scale {
		panic("loss of precision")
	}
	z := d.coef
	z.Mul(&z, exp10(scale-d.scale))
	return &Dec{
		coef:  z,
		scale: scale,
	}
}
func maxscale(x, y *Dec) (*Dec, *Dec) {
	if x.scale == y.scale {
		return x, y
	}
	if x.scale > y.scale {
		return x, y.rescale(x.scale)
	}
	return x.rescale(y.scale), y
}
func (x Dec) Cmp(y *Dec) int {
	dx, dy := maxscale(&x, y)
	return dx.coef.Cmp(&dy.coef)
}
func (d *Dec) Abs(x *Dec) *Dec {
	d.coef.Abs(&x.coef)
	if d != x {
		d.scale = x.scale
	}
	return d
}
func (d *Dec) Neg(x *Dec) *Dec {
	d.coef.Neg(&x.coef)
	if d != x {
		d.scale = x.scale
	}
	return d
}
func (d *Dec) Add(x, y *Dec) *Dec {
	dx, dy := maxscale(x, y)
	if d != dx {
		d.scale = dx.scale
	}
	d.coef.Add(&dx.coef, &dy.coef)
	return d
}
func (d *Dec) Sub(x, y *Dec) *Dec {
	dx, dy := maxscale(x, y)
	if d != dx {
		d.scale = dx.scale
	}
	d.coef.Sub(&dx.coef, &dy.coef)
	return d
}