From: Ævar Arnfjörð Bjarmason Date: Sat, 27 Feb 2010 21:08:30 +0000 (+0000) Subject: The last commit didn't correctly catch 1 v.s. 1.5, use Perl's fmod function to check... X-Git-Tag: 0.50_05~4^2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=commitdiff_plain;h=9ab5eba8f47dea20ad51f8dccb18c574399748c9;hp=1f1ccccdb5564d10867ffb11df17a5155999a62a The last commit didn't correctly catch 1 v.s. 1.5, use Perl's fmod function to check this --- diff --git a/xs-src/MouseTypeConstraints.xs b/xs-src/MouseTypeConstraints.xs index a7ff390..7068a5b 100644 --- a/xs-src/MouseTypeConstraints.xs +++ b/xs-src/MouseTypeConstraints.xs @@ -120,9 +120,14 @@ mouse_tc_Num(pTHX_ SV* const data PERL_UNUSED_DECL, SV* const sv) { int mouse_tc_Int(pTHX_ SV* const data PERL_UNUSED_DECL, SV* const sv) { assert(sv); - if(SvIOKp(sv) || SvNOKp(sv)){ + if(SvIOKp(sv)){ return TRUE; } + else if(SvNOKp(sv)) { + NV const nv = SvNVX(sv); + NV mod = Perl_fmod( nv, 1 ); + return mod == 0; + } else if(SvPOKp(sv)){ int const num_type = grok_number(SvPVX(sv), SvCUR(sv), NULL); if(num_type){