ext/numo/narray/array.c in numo-narray-0.9.1.7 vs ext/numo/narray/array.c in numo-narray-0.9.1.8

- old
+ new

@@ -28,10 +28,13 @@ static ID id_end; static ID id_step; static ID id_abs; static ID id_cast; static ID id_le; +#if SIZEOF_LONG <= 4 +static ID id_ge; +#endif static ID id_Complex; static VALUE int32_max = Qnil; static VALUE int32_min = Qnil; static VALUE @@ -43,11 +46,11 @@ case T_FALSE: if (type<NA_BIT) return NA_BIT; return type; -#if SIZEOF_LONG == 4 +#if SIZEOF_LONG <= 4 case T_FIXNUM: if (type<NA_INT32) return NA_INT32; return type; case T_BIGNUM: @@ -59,16 +62,15 @@ } else { return NA_INT64; } } return type; - -#elif SIZEOF_LONG == 8 +#else case T_FIXNUM: if (type<NA_INT64) { long x = NUM2LONG(v); - if (x<=2147483647 && x>=-2147483648) { + if (x<=2147483647L && x>=-2147483648L) { if (type<NA_INT32) return NA_INT32; } else { return NA_INT64; } @@ -76,23 +78,10 @@ return type; case T_BIGNUM: if (type<NA_INT64) return NA_INT64; return type; -#else - case T_FIXNUM: - case T_BIGNUM: - if (type<NA_INT64) { - if (RTEST(rb_funcall(v,id_le,1,int32_max)) && - RTEST(rb_funcall(v,id_ge,1,int32_min))) { - if (type<NA_INT32) - return NA_INT32; - } else { - return NA_INT64; - } - } - return type; #endif case T_FLOAT: if (type<NA_DFLOAT) return NA_DFLOAT; @@ -643,9 +632,12 @@ id_end = rb_intern("end"); id_step = rb_intern("step"); id_cast = rb_intern("cast"); id_abs = rb_intern("abs"); id_le = rb_intern("<="); +#if SIZEOF_LONG <= 4 + id_ge = rb_intern(">="); +#endif id_Complex = rb_intern("Complex"); rb_global_variable(&int32_max); int32_max = INT2NUM(2147483647); rb_global_variable(&int32_min);