in reply to How can I test for the representation of an integer?
Cheers,#!perl -l use strict; use warnings; use Math::BigInt; use Inline C => Config => BUILD_NOISY => 1; use Inline C => <<'EOC'; int is_IV(SV * x) { if(SvIOK(x)) return 1; return 0; } EOC my $x = '42'; print is_IV($x); # 0 $x += 0; print is_IV($x); # 1 print is_IV(~0); # 1 (also UV) print is_IV('?'); # 0; my $mbi = Math::BigInt->new(1); print is_IV($mbi); # 0; print is_IV(2 ** 20); # 0 (NV)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: How can I test for the representation of an integer?
by sm@sh (Acolyte) on Apr 25, 2016 at 14:24 UTC |