The last commit didn't correctly catch 1 v.s. 1.5, use Perl's fmod function to check...
[gitmo/Mouse.git] / xs-src / MouseTypeConstraints.xs
index a7ff390..7068a5b 100644 (file)
@@ -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){