Natural number addition

@param NI $a first operand
@param NI $b second operand

@return NaturalIntType
497414
public function naturalAdd(NI $a, NI $b)
    {
        list($a, $b) = $this->checkIntTypes($a, $b);
        return new NaturalIntType($a() + $b());
    }
1155253
public function compare(DecimalNumber $a, DecimalNumber $b)
    {
        if (function_exists('bccomp')) {
            return $this->compareUsingBcMath($a, $b);
        }

        return $this->compareWithoutBcMath($a, $b);
    }
1207008
public static function MOD($a = 1, $b = 1)
    {
        $a = PHPExcel_Calculation_Functions::flattenSingleValue($a);
        $b = PHPExcel_Calculation_Functions::flattenSingleValue($b);

        if ($b == 0.0) {
            return PHPExcel_Calculation_Functions::DIV0();
        } elseif (($a < 0.0) && ($b > 0.0)) {
            return $b - fmod(abs($a), $b);
        } elseif (($a > 0.0) && ($b < 0.0)) {
            return $b + fmod($a, abs($b));
        }

        return fmod($a, $b);
    }
352350
private function gcd($a, $b)
    {
        return $b ? $this->gcd($b, $a % $b) : $a;
    }
767940
private static  Number times(Number a, Number b) 
  {
    int aType = getType(a);
    int bType = getType(b);
    
    int compType = (aType >= bType) ? aType : bType;
    switch (compType)  
    {
      case INT :
        return new Integer(a.intValue() * b.intValue());
      case LONG :
        return new Long(a.longValue() * b.longValue());
      case FLOAT :
        return new Float(a.floatValue() * b.floatValue());
      case DOUBLE :
        return new Double(a.doubleValue() * b.doubleValue());
      default :
        throw new IllegalStateException();
    }
  }
1327552
public static function unsignedRightShift(int $a, int $b) : int
    {
        return (
            $a >= 0
            ? $a >> $b
            : (($a & 0x7fffffff) >> $b) | (0x40000000 >> ($b - 1))
        );
    }
859540
public static function sicrediNossoNumero($agencia, $posto, $conta, $ano, $byte, $numero_boleto)
    {
        $n = Util::numberFormatGeral($agencia, 4)
            . Util::numberFormatGeral($posto, 2)
            . Util::numberFormatGeral($conta, 5)
            . Util::numberFormatGeral($ano, 2)
            . Util::numberFormatGeral($byte, 1)
            . Util::numberFormatGeral($numero_boleto, 5);
        return  Util::modulo11($n);
    }
1033279
public static function multiply($a, $b)
    {
        if (function_exists('gmp_mul')) {
            return gmp_mul($a, $b);
        }

        return bcmul($a, $b, 0);
    }
778253
public function gcd( $m, $n )
	{
		if( $n != 0 )
			return NaturalNumbers::gcd( $n, $m % $n );
		else
			return $m;
	}
732085
public function naturalSub(NI $a, NI $b)
    {
        list($a, $b) = $this->checkIntTypes($a, $b);
        return new NaturalIntType($a() - $b());
    }
1109191
public FDBigInt
    add( FDBigInt other ){
        int i;
        int a[], b[];
        int n, m;
        long c = 0L;
        // arrange such that a.nWords >= b.nWords;
        // n = a.nWords, m = b.nWords
        if ( this.nWords >= other.nWords ){
            a = this.data;
            n = this.nWords;
            b = other.data;
            m = other.nWords;
        } else {
            a = other.data;
            n = other.nWords;
            b = this.data;
            m = this.nWords;
        }
        int r[] = new int[ n ];
        for ( i = 0; i < n; i++ ){
            c += (long)a[i] & 0xffffffffL;
            if ( i < m ){
                c += (long)b[i] & 0xffffffffL;
            }
            r[i] = (int) c;
            c >>= 32; // signed shift.
        }
        if ( c != 0L ){
            // oops -- carry out -- need longer result.
            int s[] = new int[ r.length+1 ];
            System.arraycopy( r, 0, s, 0, r.length );
            s[i++] = (int)c;
            return new FDBigInt( s, i );
        }
        return new FDBigInt( r, i );
    }
577882
@Inline(value="$1.add($2)")
	@Pure
	public static BigInteger operator_plus(BigInteger a, BigInteger b) {
		return a.add(b);
	}
197658
public function add($a, $b)
    {
        return bcadd($this->bcNormalize($a), $this->bcNormalize($b));
    }
600180
private function unsignedRightShift($a, $b)
    {
        if ($b >= 32 || $b < -32) {
            $m = (int)($b / 32);
            $b = $b - ($m * 32);
        }

        if ($b < 0) {
            $b = 32 + $b;
        }

        if ($b == 0) {
            return (($a >> 1) & 0x7fffffff) * 2 + (($a >> $b) & 1);
        }

        if ($a < 0) {
            $a = ($a >> 1);
            $a &= 2147483647;
            $a |= 0x40000000;
            $a = ($a >> ($b - 1));
        } else { 
            $a = ($a >> $b);
        }

        return $a;
    }
1341890
public function wholeAdd(NI $a, NI $b)
    {
        list($a, $b) = $this->checkIntTypes($a, $b);
        return new WholeIntType($a() + $b());
    }
766185
public function comp($a, $b)
    {
        return bccomp($this->bcNormalize($a), $this->bcNormalize($b));
    }
285125
public function computeUsingBcMath(DecimalNumber $a, DecimalNumber $b)
    {
        $precision1 = $a->getPrecision();
        $precision2 = $b->getPrecision();
        return new DecimalNumber((string) bcadd($a, $b, max($precision1, $precision2)));
    }