use Math::GMP; use Math::GMPz; use Inline C => Config => LIBS => '-lgmp', BUILD_NOISY => 1, USING => ParseRecDescent; use Inline C => <<'EOC'; #include void my_mul_si(SV * rop, SV * op, SV * si) { mpz_mul_si (*(INT2PTR(mpz_t *, SvIV(SvRV(rop)))), *(INT2PTR(mpz_t *, SvIV(SvRV(op)))), SvIV(si)); } EOC my $ x = -10; my $g_rop = Math::GMP->new(); my $g_op = Math::GMP->new(1234567); my $z_rop = Math::GMPz->new(); my $z_op = Math::GMPz->new(1234567); my_mul_si($g_rop, $g_op, $x); my_mul_si($z_rop, $z_op, $x); my_mul_si($g_op, $g_op, $x); my_mul_si($z_op, $z_op, $x); print $g_rop, "\n", $z_rop, "\n", $g_op, "\n", $z_op, "\n"; __END__ Outputs: -12345670 -12345670 -12345670 -12345670 #### use Math::BigInt lib => 'GMP'; use warnings; use strict; use Inline C => Config => BUILD_NOISY => 1; use Inline C => <<'EOC'; void derivation(SV * obj) { if(sv_derived_from(obj, "Math::BigInt::GMP")) printf("A Math::BigInt::GMP object\n"); else printf("Not a Math::BigInt::GMP object\n"); if(sv_derived_from(obj, "Math::BigInt")) printf("A Math::BigInt object\n"); else printf("Not a Math::BigInt object\n"); } EOC my $o = Math::BigInt->new(1234); derivation($o); __END__ Outputs: Not a Math::BigInt::GMP object A Math::BigInt object