use Math::BigInt lib => 'GMP'; use Inline C => Config => LIBS => '-lgmp', USING => 'ParseRegExp', BUILD_NOISY => 1; use Inline C => <<'EOC'; #include mpz_t * mpz_from_sv_nofail (SV *sv) { MAGIC *mg; if (!sv_derived_from(sv, "Math::BigInt::GMP")) croak("not of type Math::BigInt::GMP"); mg = SvMAGIC(SvRV(sv)); return (mpz_t *)mg->mg_ptr; } mpz_t * mpz_from_sv (SV *sv) { mpz_t *mpz; if (!(mpz = mpz_from_sv_nofail(sv))) croak("failed to fetch mpz pointer"); return mpz; } void my_mul(SV * bi_rop, SV * bi_op, SV * si) { mpz_t *t1, *t2; t1 = mpz_from_sv(bi_rop); t2 = mpz_from_sv(bi_op); mpz_mul_si(*t1, *t2, SvIV(si) * 10); } EOC my $rop = Math::BigInt->new(0); my $op = Math::BigInt->new(123456); my $x = -110; my_mul($rop->{value}, $op->{value}, $x); print $rop, "\n"; __END__ Outputs: -13580160