@@ -385,16 +385,34 @@ struct BigInt < Int
385385 BigInt .new { |mpz | LibGMP .com(mpz, self ) }
386386 end
387387
388+ def & (other : BigInt ) : BigInt
389+ BigInt .new { |mpz | LibGMP .and (mpz, self , other) }
390+ end
391+
388392 def & (other : Int ) : BigInt
389- BigInt .new { |mpz | LibGMP .and (mpz, self , other.to_big_i) }
393+ ret = other.to_big_i
394+ LibGMP .and (ret, ret, self )
395+ ret
396+ end
397+
398+ def | (other : BigInt ) : BigInt
399+ BigInt .new { |mpz | LibGMP .ior(mpz, self , other) }
390400 end
391401
392402 def | (other : Int ) : BigInt
393- BigInt .new { |mpz | LibGMP .ior(mpz, self , other.to_big_i) }
403+ ret = other.to_big_i
404+ LibGMP .ior(ret, ret, self )
405+ ret
406+ end
407+
408+ def ^ (other : BigInt ) : BigInt
409+ BigInt .new { |mpz | LibGMP .xor(mpz, self , other) }
394410 end
395411
396412 def ^ (other : Int ) : BigInt
397- BigInt .new { |mpz | LibGMP .xor(mpz, self , other.to_big_i) }
413+ ret = other.to_big_i
414+ LibGMP .xor(ret, ret, self )
415+ ret
398416 end
399417
400418 def >> (other : Int ) : BigInt
0 commit comments