Add missing functions from rust-bignum

This code was taken directly from jsanders/rust-bignum.

Moving this code here would allow rust-bignum to not keep a local copy of rust-gmp.