code: func (d *MyDecimal) ToInt() (int64, error) {
  	var x int64
  	wordIdx := 0
  	for i := d.digitsInt; i > 0; i -= digitsPerWord {
  		y := x
  		/*
  		   Attention: trick!
  		   we're calculating -|from| instead of |from| here
  		   because |LONGLONG_MIN| > LONGLONG_MAX
  		   so we can convert -9223372036854775808 correctly
  		*/
  		x = x*wordBase - int64(d.wordBuf[wordIdx])
  		wordIdx++
  		if y < math.MinInt64/wordBase || x > y {
  			/*
  			   the decimal is bigger than any possible integer
  			   return border integer depending on the sign
  			*/
  			if d.negative {
  				return math.MinInt64, ErrOverflow
  			}
  			return math.MaxInt64, ErrOverflow
  		}
  	}
  	/* boundary case: 9223372036854775808 */
  	if !d.negative && x == math.MinInt64 {
  		return math.MaxInt64, ErrOverflow
  	}
  	if !d.negative {
  		x = -x
  	}
  	for i := d.digitsFrac; i > 0; i -= digitsPerWord {
  		if d.wordBuf[wordIdx] != 0 {
  			return x, ErrTruncated
  		}
  		wordIdx++
  	}
  	return x, nil
  }
docs: // ToInt returns int part of the decimal, returns the result and errcode.