public static int num2uint(IRubyObject value) { long longVal = RubyNumeric.num2long(value); if (longVal > UINT_MAX) throw value.getRuntime().newRangeError("Integer " + longVal + " too big to convert to 'unsigned int'"); long num = longVal; if (num > Integer.MAX_VALUE || num < Integer.MIN_VALUE) // encode to UINT32 num = (-longVal ^ (-1l >>> 32) ) + 1; RubyNumeric.checkInt(value, num); return (int) num; }
/** rb_num2int, NUM2INT * */ public static int num2int(IRubyObject arg) { long num = num2long(arg); checkInt(arg, num); return (int)num; }
public static int fix2int(RubyFixnum arg) { long num = arg.getLongValue(); checkInt(arg, num); return (int) num; }
public static int fix2int(RubyFixnum arg) { long num = arg.getLongValue(); checkInt(arg, num); return (int) num; }
/** rb_num2int, NUM2INT * */ public static int num2int(IRubyObject arg) { long num = num2long(arg); checkInt(arg, num); return (int)num; }
/** rb_num2int, NUM2INT * */ public static int num2int(IRubyObject arg) { long num = num2long(arg); checkInt(arg, num); return (int)num; }
public static int fix2int(RubyFixnum arg) { long num = arg.getLongValue(); checkInt(arg, num); return (int) num; }
/** rb_num2int, NUM2INT * */ public static int num2int(IRubyObject arg) { long num = num2long(arg); checkInt(arg, num); return (int)num; }
public static int fix2int(RubyFixnum arg) { long num = arg.getLongValue(); checkInt(arg, num); return (int) num; }
public static int fix2int(IRubyObject arg) { long num = arg instanceof RubyFixnum ? fix2long(arg) : num2long(arg); checkInt(arg, num); return (int) num; }
public static int fix2int(IRubyObject arg) { long num = arg instanceof RubyFixnum ? fix2long(arg) : num2long(arg); checkInt(arg, num); return (int) num; }
public static int fix2int(IRubyObject arg) { long num = arg instanceof RubyFixnum ? fix2long(arg) : num2long(arg); checkInt(arg, num); return (int) num; }
public static int fix2int(IRubyObject arg) { long num = arg instanceof RubyFixnum ? fix2long(arg) : num2long(arg); checkInt(arg, num); return (int) num; }
private RubyDate prevNextDay(ThreadContext context, IRubyObject n, final boolean negate) { long seconds = timesIntDiff(context, n, DAY_IN_SECONDS); if (negate) seconds = -seconds; final int days = RubyNumeric.checkInt(context.runtime, seconds / DAY_IN_SECONDS); return newInstance(context, this.dt.plusDays(days).plusSeconds((int) (seconds % DAY_IN_SECONDS)), off, start); }
private RubyDate prevNextDay(ThreadContext context, IRubyObject n, final boolean negate) { long seconds = timesIntDiff(context, n, DAY_IN_SECONDS); if (negate) seconds = -seconds; final int days = RubyNumeric.checkInt(context.runtime, seconds / DAY_IN_SECONDS); return newInstance(context, this.dt.plusDays(days).plusSeconds((int) (seconds % DAY_IN_SECONDS)), off, start); }
private RubyDate prevNextYear(ThreadContext context, IRubyObject n, final boolean negate) { long months = timesIntDiff(context, n, 12); if (negate) months = -months; // prev_year final int years = RubyNumeric.checkInt(context.runtime, months / 12); return newInstance(context, this.dt.plusYears(years).plusMonths((int) (months % 12)), off, start); }
private RubyDate prevNextYear(ThreadContext context, IRubyObject n, final boolean negate) { long months = timesIntDiff(context, n, 12); if (negate) months = -months; // prev_year final int years = RubyNumeric.checkInt(context.runtime, months / 12); return newInstance(context, this.dt.plusYears(years).plusMonths((int) (months % 12)), off, start); }