Package org.jruby
Class RubyInteger
java.lang.Object
org.jruby.RubyBasicObject
org.jruby.RubyObject
org.jruby.RubyNumeric
org.jruby.RubyInteger
- All Implemented Interfaces:
Serializable,Cloneable,Comparable<IRubyObject>,InstanceVariables,InternalVariables,IRubyObject,CoreObjectType
- Direct Known Subclasses:
RubyBignum,RubyFixnum
Implementation of the Integer class.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.jruby.RubyNumeric
RubyNumeric.InvalidIntegerException, RubyNumeric.NumberTooLargeExceptionNested classes/interfaces inherited from class org.jruby.RubyObject
RubyObject.DataNested classes/interfaces inherited from class org.jruby.RubyBasicObject
RubyBasicObject.Finalizer -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final long(package private) static final ByteList[]static final ByteList[]Deprecated.(package private) static final ByteList[]Fields inherited from class org.jruby.RubyNumeric
DBL_EPSILONFields inherited from class org.jruby.RubyObject
IVAR_INSPECTING_OBJECT_ALLOCATOR, OBJECT_ALLOCATOR, REIFYING_OBJECT_ALLOCATORFields inherited from class org.jruby.RubyBasicObject
ALL_F, BASICOBJECT_ALLOCATOR, COMPARE_BY_IDENTITY_F, ERR_INSECURE_SET_INST_VAR, FALSE_F, FL_USHIFT, flags, FROZEN_F, IS_OVERLAID_F, metaClass, NEVER, NIL_F, REFINED_MODULE_F, STAMP_OFFSET, TAINTED_F, UNDEF, UNTRUST_F, USER0_F, USER1_F, USER2_F, USER3_F, USER4_F, USER5_F, USER6_F, USER7_F, USER8_F, USER9_F, USERA_F, VAR_TABLE_OFFSET, varTable, varTableStampFields inherited from interface org.jruby.runtime.builtin.IRubyObject
NULL_ARRAY -
Constructor Summary
ConstructorsConstructorDescriptionRubyInteger(RubyClass rubyClass) RubyInteger(Ruby runtime, RubyClass rubyClass) RubyInteger(Ruby runtime, RubyClass rubyClass, boolean useObjectSpace) RubyInteger(Ruby runtime, RubyClass rubyClass, boolean useObjectSpace, boolean canBeTainted) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionabstract IRubyObjectabs(ThreadContext context) num_absallbits_p(ThreadContext context, IRubyObject other) anybits_p(ThreadContext context, IRubyObject other) abstract IRubyObjectbit_length(ThreadContext context) ceil()Deprecated.ceil(ThreadContext context) MRI: num_ceilabstract IRubyObjectceil(ThreadContext context, IRubyObject arg) chr(ThreadContext context) int_chrchr(ThreadContext context, IRubyObject arg) final RubyStringchr19(ThreadContext context) Deprecated.chr19(ThreadContext context, IRubyObject arg) Deprecated.private RubyStringchrCommon(ThreadContext context, long value, org.jcodings.Encoding enc) Tries to convert this object to a Ruby Integer using the "to_int" method.static RubyClasscreateIntegerClass(Ruby runtime) denominator(ThreadContext context) numeric_denominatordigits(ThreadContext context) abstract RubyArraydigits(ThreadContext context, IRubyObject base) final IRubyObjectdiv_div(ThreadContext context, IRubyObject other) divmod(ThreadContext context, IRubyObject other) num_divmodprivate static longdoRound(ThreadContext context, RoundingMode roundingMode, long n, long f) private static booleandoRoundCheck(ThreadContext context, RoundingMode roundingMode, RubyInteger num, RubyNumeric n, IRubyObject f) downto(ThreadContext context, IRubyObject to, Block block) int_downtoprivate static IRubyObjectdowntoSize(ThreadContext context, IRubyObject recv, IRubyObject[] args) A downto size method suitable for lambda method reference implementation ofRubyEnumerator.SizeFn.size(ThreadContext, IRubyObject, IRubyObject[])private static voidduckDownto(ThreadContext context, IRubyObject from, IRubyObject to, Block block) (package private) static voidduckUpto(ThreadContext context, IRubyObject from, IRubyObject to, Block block) even_p(ThreadContext context) fdiv(ThreadContext context, IRubyObject y) num_fdivabstract IRubyObjectfdivDouble(ThreadContext context, IRubyObject y) private static voidfixnumDownto(ThreadContext context, long from, long to, Block block) (package private) static voidfixnumUpto(ThreadContext context, long from, long to, Block block) floor()Deprecated.floor(ThreadContext context) MRI: num_floorabstract IRubyObjectfloor(ThreadContext context, IRubyObject arg) static final longfloorSqrt(long x) static final BigIntegergcd(ThreadContext context, IRubyObject other) rb_gcdgcdlcm(ThreadContext context, IRubyObject other) rb_gcdlcmabstract IRubyObjectidiv(ThreadContext context, IRubyObject other) MRI: rb_int_idiv and overridesstatic IRubyObjectinduced_from(ThreadContext context, IRubyObject recv, IRubyObject other) Deprecated.protected static booleanint_half_p_half_down(ThreadContext context, RubyInteger num, RubyNumeric n, IRubyObject f) protected static booleanint_half_p_half_even(ThreadContext context, RubyInteger num, RubyNumeric n, IRubyObject f) protected static booleanint_half_p_half_up(ThreadContext context, RubyInteger num, RubyNumeric n, IRubyObject f) protected static longint_round_half_down(long x, long y) protected static longint_round_half_even(long x, long y) protected static longint_round_half_up(long x, long y) protected booleanint_round_zero_p(ThreadContext context, int ndigits) int_int_pprivate static CallSiteinteger_p(ThreadContext context) protected IRubyObjectintPowTmp3(ThreadContext context, RubyInteger y, RubyBignum m, boolean negaFlg) (package private) static RubyIntegerintValue(ThreadContext context, IRubyObject num) booleanisNegative(ThreadContext context) num_negative_p(package private) booleanisOne()booleanisPositive(ThreadContext context) num_positive_plcm(ThreadContext context, IRubyObject other) rb_lcmmagnitude(ThreadContext context) num_abs/1.9negate()nobits_p(ThreadContext context, IRubyObject other) numerator(ThreadContext context) numeric_numeratorodd_p(ThreadContext context) abstract IRubyObjectop_and(ThreadContext context, IRubyObject other) op_aref(IRubyObject other) abstract IRubyObjectop_aref(ThreadContext context, IRubyObject other) abstract IRubyObjectop_cmp(ThreadContext context, IRubyObject other) abstract IRubyObjectop_div(ThreadContext context, IRubyObject other) abstract IRubyObjectop_equal(ThreadContext context, IRubyObject other) rb_obj_equal Will by default use identity equality to compare objects.op_ge(ThreadContext context, IRubyObject other) op_gt(ThreadContext context, IRubyObject other) final IRubyObjectop_idiv(ThreadContext context, IRubyObject arg) Deprecated.op_le(ThreadContext context, IRubyObject other) op_lshift(IRubyObject other) Deprecated.op_lshift(ThreadContext context, long other) abstract IRubyObjectop_lshift(ThreadContext context, IRubyObject other) op_lt(ThreadContext context, IRubyObject other) op_minus(ThreadContext context, long other) abstract IRubyObjectop_minus(ThreadContext context, IRubyObject other) op_mod(ThreadContext context, long other) abstract IRubyObjectop_mod(ThreadContext context, IRubyObject other) private static longop_mod_two(ThreadContext context, RubyInteger self) op_mul(ThreadContext context, long other) abstract IRubyObjectop_mul(ThreadContext context, IRubyObject other) op_neg()abstract IRubyObjectop_neg(ThreadContext context) abstract IRubyObjectop_or(ThreadContext context, IRubyObject other) op_plus(ThreadContext context, long other) abstract IRubyObjectop_plus(ThreadContext context, IRubyObject other) abstract IRubyObjectop_pow(ThreadContext context, IRubyObject other) op_rshift(IRubyObject other) Deprecated.op_rshift(ThreadContext context, long other) abstract IRubyObjectop_rshift(ThreadContext context, IRubyObject other) abstract IRubyObjectop_uminus(ThreadContext context) num_uminusabstract IRubyObjectop_xor(ThreadContext context, IRubyObject other) ord(ThreadContext context) int_ordpow(ThreadContext context, IRubyObject other) pow(ThreadContext context, IRubyObject b, IRubyObject m) pred(ThreadContext context) rationalize(ThreadContext context, IRubyObject[] args) integer_rationalizeremainder(ThreadContext context, IRubyObject dividend) num_remainderround()Deprecated.round(ThreadContext context) MRI: num_roundround(ThreadContext context, int ndigits) round(ThreadContext context, IRubyObject _digits) round(ThreadContext context, IRubyObject digits, IRubyObject _opts) final IRubyObjectround19()Deprecated.final IRubyObjectround19(ThreadContext context, IRubyObject arg) Deprecated.roundShared(ThreadContext context, int ndigits, RoundingMode roundingMode) intsignum()static ByteListsingleCharByteList(byte index) static RubyStringsingleCharString(Ruby runtime, byte b, RubyClass meta, org.jcodings.Encoding enc) Return a single-character ByteList, possibly cached, corresponding to the given byte and encoding.static ByteListsingleCharUTF8ByteList(byte index) Return a low ASCII single-character bytelist with UTF-8 encoding, using cached values.private static JavaSites.IntegerSitessites(ThreadContext context) size()abstract IRubyObjectsize(ThreadContext context) abstract IRubyObjectsqrt(ThreadContext context) static IRubyObjectsqrt(ThreadContext context, IRubyObject self, IRubyObject num) rb_int_s_isqrtsucc(ThreadContext context) int_succtimes(ThreadContext context, Block block) protected static IRubyObjecttimesSize(ThreadContext context, RubyInteger recv, IRubyObject[] args) A times size method suitable for lambda method reference implementation ofRubyEnumerator.SizeFn.size(ThreadContext, IRubyObject, IRubyObject[])to_f()abstract IRubyObjectto_f(ThreadContext context) to_i()int_to_ito_r(ThreadContext context) integer_to_rabstract RubyStringto_s()rb_any_to_s call-seq: obj.to_s => string Returns a string representing obj.abstract RubyStringto_s(IRubyObject x) protected RubyFloattoFloat()(package private) static RubyIntegertoInteger(ThreadContext context, IRubyObject num) truncate()Deprecated.truncate(ThreadContext context) MRI: num_truncateabstract IRubyObjecttruncate(ThreadContext context, IRubyObject arg) upto(ThreadContext context, IRubyObject to, Block block) int_uptoprivate static IRubyObjectuptoSize(ThreadContext context, IRubyObject from, IRubyObject[] args) An upto size method suitable for lambda method reference implementation ofRubyEnumerator.SizeFn.size(ThreadContext, IRubyObject, IRubyObject[])abstract IRubyObjectzero_p(ThreadContext context) num_zero_pMethods inherited from class org.jruby.RubyNumeric
abs2, arg, asNumeric, callCoerced, callCoerced, callCoerced, callCoerced, checkInt, checkInt, coerce, coerceBin, coerceBin, coerceBit, coerceBit, coerceBody, coerceCmp, coerceCmp, coerceFailed, coerceRelOp, coerceRelOp, coerceRescue, compareWithZero, conjugate, convertToRational, createNumericClass, dbl_cmp, dbl2ival, dbl2num, div, div19, divmod19, doCoerce, dup, eql_p, finite_p, fix2int, fix2int, fix2long, fixable, float2long, float2ulong, floatStep, floatStep, floatStepSize, getBigIntegerValue, getCoerced, getDoubleValue, getIntValue, getLongValue, getRoundingMode, idiv, image, infinite_p, initialize_copy, int2fix, intervalStepSize, isReal, isZero, modulo, modulo, modulo19, negativeInt, negFixable, negFixable, newNumeric, nonzero_p, num_imaginary, num2chr, num2dbl, num2dbl, num2fix, num2int, num2long, num2ulong, numFuncall, numFuncall, numRemainder, op_cmp, op_not, op_num_equal, op_uplus, polar, posFixable, posFixable, positiveInt, quo, quo_19, rbClone, rbClone, rbClone, rbClone, real, real_p, rect, scalar_p, singleton_method_added, step, str2fnum, str2fnum, str2fnum, str2fnum19, str2inum, str2inum, str2inum, to_c, to_int, toJavaMethods inherited from class org.jruby.RubyObject
attachToObjectSpace, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, convertToType, createObjectClass, dig, dig1, dig2, eqlInternal, equalInternal, equals, getNativeClassIndex, hashCode, inspect, op_eqq, puts, specificEval, toRubyString, toStringMethods inherited from class org.jruby.RubyBasicObject
addFinalizer, anyToString, asJavaString, asString, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callSuper, checkArrayType, checkCallMethod, checkCallMethod, checkFrozen, checkStringType, checkStringType19, compareTo, convertToArray, convertToFloat, convertToHash, convertToInteger, convertToInteger, convertToString, copyInstanceVariablesInto, copySpecialInstanceVariables, createBasicObjectClass, dataGetStruct, dataGetStructChecked, dataWrapStruct, decode, defaultToJava, display, ensureInstanceVariablesSettable, eql, eql_p, equal_p, equal_p19, evalUnder, extend, fastGetInstanceVariable, fastGetInternalVariable, fastHasInstanceVariable, fastHasInternalVariable, fastSetInstanceVariable, fastSetInternalVariable, freeze, frozen_p, getFFIHandle, getFlag, getInstanceEvalClass, getInstanceVariable, getInstanceVariableList, getInstanceVariableNameList, getInstanceVariables, getInternalVariable, getInternalVariables, getJavaClass, getMetaClass, getMetaClass, getNativeHandle, getNativeTypeIndex, getObjectId, getRuntime, getSingletonClass, getSingletonClassClone, getSingletonClassCloneAndAttach, getType, getVariable, getVariableCount, getVariableList, getVariableNameList, hash, hashyInspect, hasInstanceVariable, hasInstanceVariables, hasInternalVariable, hasVariables, id, infectBy, infectBy, infectBy, initialize, initialize19, inspect, inspectHashCode, instance_eval, instance_eval, instance_eval, instance_eval, instance_eval19, instance_eval19, instance_eval19, instance_eval19, instance_exec, instance_exec19, instance_of_p, instance_variable_defined_p, instance_variable_get, instance_variable_set, instance_variables, instance_variables19, isBuiltin, isClass, isFalse, isFrozen, isImmediate, isModule, isNil, isSpecialConst, isSpecialObject, isTaint, isTrue, isUntrusted, kind_of_p, makeMetaClass, method, method_missing, method_missing19, method19, methods, methods, methods19, methodsImpl, nil_p, nonFixnumHashCode, OBJ_INIT_COPY, objInitCopy, op_equal_19, op_match, op_match19, op_not_equal, op_not_match, private_methods, private_methods19, protected_methods, protected_methods19, public_methods, public_methods19, rbInspect, recacheBuiltinMethods, remove_instance_variable, removeFinalizers, removeInstanceVariable, removeInternalVariable, respond_to_p, respond_to_p, respond_to_p, respond_to_p19, respond_to_p19, respondsTo, respondsToMissing, respondsToMissing, send, send, send, send, send, send19, send19, send19, send19, setFFIHandle, setFlag, setFrozen, setInstanceVariable, setInternalVariable, setMetaClass, setNativeHandle, setTaint, setUntrusted, setVariable, singleton_method, singleton_method_added, singleton_method_added19, singleton_method_removed, singleton_method_removed19, singleton_method_undefined, singleton_method_undefined19, singleton_methods, specificEval, specificEval, specificEval, specificEval, syncVariables, syncVariables, taint, taint, tainted, tainted_p, testFrozen, testFrozen, to_a, to_a, trust, type, type_deprecated, untaint, untrust, untrusted_p, validateInstanceVariable, validateInstanceVariable, validateInstanceVariable, variableTableContains, variableTableFastContains, variableTableFastFetch, variableTableFastStore, variableTableFetch, variableTableRemove, variableTableStore, variableTableSync, yieldUnder, yieldUnder
-
Field Details
-
SINGLE_CHAR_BYTELISTS
-
SINGLE_CHAR_BYTELISTS19
Deprecated. -
SINGLE_CHAR_UTF8_BYTELISTS
-
HALF_LONG_MSB
private static final long HALF_LONG_MSB- See Also:
-
-
Constructor Details
-
RubyInteger
-
RubyInteger
-
RubyInteger
-
RubyInteger
@Deprecated public RubyInteger(Ruby runtime, RubyClass rubyClass, boolean useObjectSpace, boolean canBeTainted) Deprecated.
-
-
Method Details
-
createIntegerClass
-
convertToInteger
Description copied from class:RubyBasicObjectTries to convert this object to a Ruby Integer using the "to_int" method.- Specified by:
convertToIntegerin interfaceIRubyObject- Overrides:
convertToIntegerin classRubyBasicObject- Returns:
- an integer representation of this
-
toFloat
-
signum
public int signum() -
negate
-
isNegative
Description copied from class:RubyNumericnum_negative_p- Overrides:
isNegativein classRubyNumeric
-
isPositive
Description copied from class:RubyNumericnum_positive_p- Overrides:
isPositivein classRubyNumeric
-
isNegative
public boolean isNegative()- Overrides:
isNegativein classRubyNumeric
-
isPositive
public boolean isPositive()- Overrides:
isPositivein classRubyNumeric
-
sqrt
rb_int_s_isqrt -
sqrt
-
floorSqrt
public static final long floorSqrt(long x) -
floorSqrt
-
integer_p
int_int_p- Overrides:
integer_pin classRubyNumeric
-
upto
int_upto -
fixnumUpto
-
duckUpto
-
uptoSize
An upto size method suitable for lambda method reference implementation ofRubyEnumerator.SizeFn.size(ThreadContext, IRubyObject, IRubyObject[]) -
downto
int_downto -
fixnumDownto
-
duckDownto
private static void duckDownto(ThreadContext context, IRubyObject from, IRubyObject to, Block block) -
downtoSize
A downto size method suitable for lambda method reference implementation ofRubyEnumerator.SizeFn.size(ThreadContext, IRubyObject, IRubyObject[]) -
times
-
timesSize
A times size method suitable for lambda method reference implementation ofRubyEnumerator.SizeFn.size(ThreadContext, IRubyObject, IRubyObject[]) -
succ
int_succ -
singleCharByteList
-
singleCharUTF8ByteList
Return a low ASCII single-character bytelist with UTF-8 encoding, using cached values. The resulting ByteList should not be modified.- Parameters:
index- the byte- Returns:
- a cached single-character ByteList
-
singleCharString
public static RubyString singleCharString(Ruby runtime, byte b, RubyClass meta, org.jcodings.Encoding enc) Return a single-character ByteList, possibly cached, corresponding to the given byte and encoding. Note this will return high ASCII non-UTF8 characters as ASCII-8BIT, rather than US-ASCII.- Parameters:
b- the byteenc- the encoding- Returns:
- a new single-character RubyString
-
chr
int_chr -
chr19
Deprecated. -
chr
-
chr19
Deprecated. -
chrCommon
-
ord
int_ord -
to_i
int_to_i -
ceil
Description copied from class:RubyNumericMRI: num_ceil- Overrides:
ceilin classRubyNumeric
-
ceil
-
floor
Description copied from class:RubyNumericMRI: num_floor- Overrides:
floorin classRubyNumeric
-
floor
-
truncate
Description copied from class:RubyNumericMRI: num_truncate- Overrides:
truncatein classRubyNumeric
-
truncate
-
round
Description copied from class:RubyNumericMRI: num_round- Overrides:
roundin classRubyNumeric
-
round
-
round
-
round
-
doRound
-
doRoundCheck
private static boolean doRoundCheck(ThreadContext context, RoundingMode roundingMode, RubyInteger num, RubyNumeric n, IRubyObject f) -
int_round_zero_p
-
int_round_half_even
protected static long int_round_half_even(long x, long y) -
int_round_half_up
protected static long int_round_half_up(long x, long y) -
int_round_half_down
protected static long int_round_half_down(long x, long y) -
int_half_p_half_even
protected static boolean int_half_p_half_even(ThreadContext context, RubyInteger num, RubyNumeric n, IRubyObject f) -
int_half_p_half_up
protected static boolean int_half_p_half_up(ThreadContext context, RubyInteger num, RubyNumeric n, IRubyObject f) -
int_half_p_half_down
protected static boolean int_half_p_half_down(ThreadContext context, RubyInteger num, RubyNumeric n, IRubyObject f) -
to_r
integer_to_r -
rationalize
integer_rationalize -
odd_p
-
even_p
-
op_mod_two
-
allbits_p
-
anybits_p
-
nobits_p
-
pred
-
gcd
rb_gcd -
fdiv
Description copied from class:RubyNumericnum_fdiv- Overrides:
fdivin classRubyNumeric
-
fdivDouble
-
lcm
rb_lcm -
gcdlcm
rb_gcdlcm -
intValue
-
toInteger
-
digits
-
digits
-
numerator
Description copied from class:RubyNumericnumeric_numerator- Overrides:
numeratorin classRubyNumeric
-
denominator
Description copied from class:RubyNumericnumeric_denominator- Overrides:
denominatorin classRubyNumeric
-
to_s
Description copied from class:RubyBasicObjectrb_any_to_s call-seq: obj.to_s => string Returns a string representing obj. The defaultto_sprints the object's class and an encoding of the object id. As a special case, the top-level object that is the initial execution context of Ruby programs returns ``main.''- Overrides:
to_sin classRubyBasicObject
-
to_s
-
op_uminus
Description copied from class:RubyNumericnum_uminus- Overrides:
op_uminusin classRubyNumeric
-
op_plus
- Overrides:
op_plusin classRubyNumeric
-
op_plus
-
op_minus
- Overrides:
op_minusin classRubyNumeric
-
op_minus
-
op_mul
-
op_mul
-
idiv
Description copied from class:RubyNumericMRI: rb_int_idiv and overrides- Overrides:
idivin classRubyNumeric
-
div_div
-
op_div
-
op_mod
-
op_mod
-
op_pow
-
pow
-
pow
-
intPowTmp3
protected IRubyObject intPowTmp3(ThreadContext context, RubyInteger y, RubyBignum m, boolean negaFlg) -
abs
Description copied from class:RubyNumericnum_abs- Overrides:
absin classRubyNumeric
-
magnitude
Description copied from class:RubyNumericnum_abs/1.9- Overrides:
magnitudein classRubyNumeric
-
op_equal
Description copied from class:RubyBasicObjectrb_obj_equal Will by default use identity equality to compare objects. This follows the Ruby semantics. The name of this method doesn't follow the convention because hierarchy problems- Specified by:
op_equalin interfaceIRubyObject- Overrides:
op_equalin classRubyBasicObject
-
op_cmp
- Overrides:
op_cmpin classRubyBasicObject
-
op_neg
-
op_and
-
op_or
-
op_xor
-
op_aref
-
op_lshift
-
op_lshift
-
op_rshift
-
op_rshift
-
to_f
-
size
-
zero_p
Description copied from class:RubyNumericnum_zero_p- Overrides:
zero_pin classRubyNumeric
-
bit_length
-
isOne
boolean isOne() -
op_gt
-
op_lt
-
op_ge
-
op_le
-
remainder
Description copied from class:RubyNumericnum_remainder- Overrides:
remainderin classRubyNumeric
-
divmod
Description copied from class:RubyNumericnum_divmod- Overrides:
divmodin classRubyNumeric
-
op_uminus
-
op_neg
-
op_aref
-
op_lshift
Deprecated. -
op_rshift
Deprecated. -
to_f
-
size
-
integer_p
-
sites
-
induced_from
@Deprecated public static IRubyObject induced_from(ThreadContext context, IRubyObject recv, IRubyObject other) Deprecated.rb_int_induced_from -
round
Deprecated.- Overrides:
roundin classRubyNumeric
-
ceil
Deprecated.- Overrides:
ceilin classRubyNumeric
-
floor
Deprecated.- Overrides:
floorin classRubyNumeric
-
truncate
Deprecated.Description copied from class:RubyNumericnum_truncate- Overrides:
truncatein classRubyNumeric
-
round19
Deprecated. -
round19
Deprecated. -
op_idiv
Deprecated.
-