/** rb_big_aref * */ @Override public RubyFixnum op_aref(ThreadContext context, IRubyObject other) { if (other instanceof RubyBignum) { // Need to normalize first other = bignorm(context.runtime, ((RubyBignum) other).value); if (other instanceof RubyBignum) { // '!=' for negative value if ((((RubyBignum) other).value.signum() >= 0) != (value.signum() == -1)) { return RubyFixnum.zero(context.runtime); } return RubyFixnum.one(context.runtime); } } long position = num2long(other); if (position < 0 || position > Integer.MAX_VALUE) { return RubyFixnum.zero(context.runtime); } return value.testBit((int)position) ? RubyFixnum.one(context.runtime) : RubyFixnum.zero(context.runtime); }
/** rb_big_aref * */ @Override public RubyFixnum op_aref(ThreadContext context, IRubyObject other) { if (other instanceof RubyBignum) { // Need to normalize first other = bignorm(context.runtime, ((RubyBignum) other).value); if (other instanceof RubyBignum) { // '!=' for negative value if ((((RubyBignum) other).value.signum() >= 0) != (value.signum() == -1)) { return RubyFixnum.zero(context.runtime); } return RubyFixnum.one(context.runtime); } } long position = num2long(other); if (position < 0 || position > Integer.MAX_VALUE) { return RubyFixnum.zero(context.runtime); } return value.testBit((int)position) ? RubyFixnum.one(context.runtime) : RubyFixnum.zero(context.runtime); }
/** rb_big_aref * */ @JRubyMethod(name = "[]", required = 1) public RubyFixnum op_aref(IRubyObject other) { if (other instanceof RubyBignum) { // Need to normalize first other = bignorm(getRuntime(), ((RubyBignum) other).value); if (other instanceof RubyBignum) { // '!=' for negative value if ((((RubyBignum) other).value.signum() >= 0) != (value.signum() == -1)) { return RubyFixnum.zero(getRuntime()); } return RubyFixnum.one(getRuntime()); } } long position = num2long(other); if (position < 0 || position > Integer.MAX_VALUE) { return RubyFixnum.zero(getRuntime()); } return value.testBit((int)position) ? RubyFixnum.one(getRuntime()) : RubyFixnum.zero(getRuntime()); }
/** rb_big_aref * */ @JRubyMethod(name = "[]", required = 1) public RubyFixnum op_aref(IRubyObject other) { if (other instanceof RubyBignum) { // Need to normalize first other = bignorm(getRuntime(), ((RubyBignum) other).value); if (other instanceof RubyBignum) { // '!=' for negative value if ((((RubyBignum) other).value.signum() >= 0) != (value.signum() == -1)) { return RubyFixnum.zero(getRuntime()); } return RubyFixnum.one(getRuntime()); } } long position = num2long(other); if (position < 0 || position > Integer.MAX_VALUE) { return RubyFixnum.zero(getRuntime()); } return value.testBit((int)position) ? RubyFixnum.one(getRuntime()) : RubyFixnum.zero(getRuntime()); }