func (d Decimal) Value() (driver.Value, error) {
	m := bigIntFree.Get().(*big.Int)
	neg, exp, df := convertRatToDecimal((*big.Rat)(&d), m, dec128Digits, dec128MinExp, dec128MaxExp)

	var v driver.Value
	var err error

	switch {
	default:
		v, err = encodeDecimal(m, neg, exp)
	case df&dfUnderflow != 0: // set to zero
		m.Set(natZero)
		v, err = encodeDecimal(m, false, 0)
	case df&dfOverflow != 0:
		err = ErrDecimalOutOfRange
	}

	// performance (avoid expensive defer)
	bigIntFree.Put(m)

	return v, err
}
func (d Decimal) Value() (driver.Value, error) {
	m := bigIntFree.Get().(*big.Int)
	neg, exp, df := convertRatToDecimal((*big.Rat)(&d), m, dec128Digits, dec128MinExp, dec128MaxExp)

	var v driver.Value
	var err error

	switch {
	default:
		v, err = encodeDecimal(m, neg, exp)
	case df&dfUnderflow != 0: 
		m.Set(natZero)
		v, err = encodeDecimal(m, false, 0)
	case df&dfOverflow != 0:
		err = ErrDecimalOutOfRange
	}

	
	bigIntFree.Put(m)

	return v, err
}
func ( d Decimal ) Value ( ) ( driver . Value , error ) { m := bigIntFree . Get ( ) . ( * big . Int ) neg , exp , df := convertRatToDecimal ( ( * big . Rat ) ( & d ) , m , dec128Digits , dec128MinExp , dec128MaxExp ) var v driver . Value var err error switch { default : v , err = encodeDecimal ( m , neg , exp ) case df & dfUnderflow != 0 : // set to zero m . Set ( natZero ) v , err = encodeDecimal ( m , false , 0 ) case df & dfOverflow != 0 : err = ErrDecimalOutOfRange } // performance (avoid expensive defer) bigIntFree . Put ( m ) return v , err }
// Value implements the database/sql/Valuer interface.
Value implements the database / sql / Valuer interface .