func (d *Dec) Abs(x *Dec) *Dec {
	d.coef.Abs(&x.coef)
	if d != x {
		d.scale = x.scale
	}
	return d
}
Abs sets d to |x| (the absolute value of x) and returns d.
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)
}