@@ -100,27 +100,13 @@ func NewDecimalFromInt64(unscaled int64, scale uint32) ScaledDecimal {
100100 }
101101}
102102
103- // IsNull reports whether the decimal represents NULL.
104- func (d ScaledDecimal ) IsNull () bool {
103+ // isNull reports whether the decimal represents NULL.
104+ func (d ScaledDecimal ) isNull () bool {
105105 return d .offset >= 32
106106}
107107
108- // Scale returns the decimal scale.
109- func (d ScaledDecimal ) Scale () uint32 {
110- return d .scale
111- }
112-
113- // UnscaledValue returns a copy of the unscaled integer value.
114- // For NULL decimals it returns nil.
115- func (d ScaledDecimal ) UnscaledValue () * big.Int {
116- if d .IsNull () {
117- return nil
118- }
119- return twosComplementToBigInt (d .unscaled [d .offset :])
120- }
121-
122108func (d ScaledDecimal ) ensureValidScale () error {
123- if d .IsNull () {
109+ if d .isNull () {
124110 return nil
125111 }
126112 if d .scale > maxDecimalScale {
@@ -233,25 +219,6 @@ func trimTwosComplement(bytes []byte) int {
233219 return i
234220}
235221
236- func twosComplementToBigInt (bytes []byte ) * big.Int {
237- if len (bytes ) == 0 {
238- return big .NewInt (0 )
239- }
240- if bytes [0 ]& 0x80 == 0 {
241- return new (big.Int ).SetBytes (bytes )
242- }
243-
244- inverted := make ([]byte , len (bytes ))
245- for i := range bytes {
246- inverted [i ] = ^ bytes [i ]
247- }
248-
249- magnitude := new (big.Int ).SetBytes (inverted )
250- magnitude .Add (magnitude , big .NewInt (1 ))
251- magnitude .Neg (magnitude )
252- return magnitude
253- }
254-
255222// validateDecimalText checks that the provided string is a valid decimal representation.
256223// It accepts numeric digits, optional sign, decimal point, exponent (e/E) and NaN/Infinity tokens.
257224func validateDecimalText (text string ) error {
0 commit comments