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.
- Author:
- jpetersen
- 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 TypeFieldDescriptionstatic final intstatic final intstatic final intFields 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, 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) Tries to convert this object to a Ruby Integer using the "to_int" method.static RubyClasscreateIntegerClass(ThreadContext context, RubyClass Numeric) 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_divmoddownto(ThreadContext context, IRubyObject to, Block block) int_downtoeven_p(ThreadContext context) fdiv(ThreadContext context, IRubyObject y) num_fdivabstract IRubyObjectfdivDouble(ThreadContext context, IRubyObject y) 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) integer_p(ThreadContext context) int_int_pprotected RubyNumericintegerCeil(ThreadContext context, RubyNumeric f) protected RubyNumericintegerFloor(ThreadContext context, RubyInteger f) protected IRubyObjectintPowTmp3(ThreadContext context, RubyInteger y, RubyBignum m, boolean negaFlg) isNegative(ThreadContext context) num_negative_pbooleanisNegativeNumber(ThreadContext context) isPositive(ThreadContext context) num_positive_pbooleanisPositiveNumber(ThreadContext context) lcm(ThreadContext context, IRubyObject other) rb_lcmmagnitude(ThreadContext context) num_abs/1.9negate()Deprecated.negate(ThreadContext context) nobits_p(ThreadContext context, IRubyObject other) numerator(ThreadContext context) numeric_numeratorstatic longnumToUint(IRubyObject val) Deprecated.static longnumToUint(ThreadContext context, IRubyObject val) Simulate CRuby's rb_num_to_uint by returning a single long; the top 4 bytes will be the uint and the bottom four bytes will be the result code.odd_p(ThreadContext context) abstract IRubyObjectop_and(ThreadContext context, IRubyObject other) op_aref(IRubyObject other) Deprecated.op_aref(ThreadContext context, IRubyObject index) op_aref(ThreadContext context, IRubyObject index, IRubyObject length) protected abstract IRubyObjectop_aref_subclass(ThreadContext context, IRubyObject index) abstract IRubyObjectop_cmp(ThreadContext context, IRubyObject other) num_cmpabstract 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) op_mul(ThreadContext context, long other) abstract IRubyObjectop_mul(ThreadContext context, IRubyObject other) op_neg()Deprecated.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) Deprecated.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) roundShared(ThreadContext context, int ndigits, RoundingMode roundingMode) intsignum()Deprecated.intsignum(ThreadContext context) 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.size()Deprecated.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()Deprecated.abstract IRubyObjectto_f(ThreadContext context) to_i()Deprecated.to_i(ThreadContext context) to_r(ThreadContext context) integer_to_rto_s()Deprecated.to_s(IRubyObject x) Deprecated.to_s(ThreadContext context) to_s(ThreadContext context, IRubyObject x) protected RubyFloattoFloat()truncate()Deprecated.truncate(ThreadContext context) MRI: num_truncateabstract IRubyObjecttruncate(ThreadContext context, IRubyObject arg) static IRubyObjecttry_convert(ThreadContext context, IRubyObject self, IRubyObject num) upto(ThreadContext context, IRubyObject to, Block block) int_uptoabstract IRubyObjectzero_p(ThreadContext context) num_zero_pMethods inherited from class org.jruby.RubyNumeric
abs2, arg, asBigInteger, asDouble, asInt, asLong, asNumeric, callCoerced, callCoerced, callCoerced, callCoerced, checkInt, checkInt, coerce, coerce, coerceBin, coerceBin, coerceBit, coerceBit, coerceCmp, coerceCmp, coerceFailed, coerceRelOp, coerceRelOp, coerceRescue, compareWithZero, conjugate, convertToRational, convertToRational, createNumericClass, dbl_cmp, dbl2ival, dbl2num, div, doCoerce, dup, eql_p, finite_p, fix2int, fix2int, fix2long, fixable, float2long, float2ulong, floatStep, floatStepSize, getBigIntegerValue, getCoerced, getDoubleValue, getIntValue, getLongValue, getRoundingMode, idiv, image, infinite_p, initialize_copy, int2fix, integer_p, intervalStepSize, isNegative, isPositive, isReal, isZero, isZero, modulo, negativeInt, negFixable, negFixable, newNumeric, nonzero_p, num_imaginary, num2chr, num2dbl, num2dbl, num2fix, num2fix, num2int, num2long, num2ulong, numFuncall, numFuncall, numRemainder, op_not, op_num_equal, op_uplus, op_uplus, polar, posFixable, posFixable, positiveInt, quo, rbClone, rbClone, rbClone, rbClone, real, real_p, rect, scalar_p, singleton_method_added, step, str2fnum, str2fnum, str2fnum, 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, dig, dig1, dig2, eqlInternal, equalInternal, equals, finishObjectClass, getNativeClassIndex, hashCode, inspect, op_eqq, puts, specificEval, toRubyString, toStringMethods inherited from class org.jruby.RubyBasicObject
addFinalizer, addFinalizer, anyToString, asJavaString, asString, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callSuper, checkArrayType, checkCallMethod, checkCallMethod, checkFrozen, checkStringType, cloneSetup, compareTo, convertToArray, convertToFloat, convertToHash, convertToInteger, convertToInteger, convertToString, copyInstanceVariablesInto, copySpecialInstanceVariables, dataGetStruct, dataGetStructChecked, dataWrapStruct, decode, display, dupFinalizer, dupSetup, ensureInstanceVariablesSettable, eql, eql_p, equal_p, evalUnder, extend, fastGetInstanceVariable, fastGetInternalVariable, fastHasInstanceVariable, fastHasInternalVariable, fastSetInstanceVariable, fastSetInternalVariable, finishBasicObjectClass, forEachInstanceVariable, forEachInstanceVariableName, freeze, frozen_p, getCurrentContext, getFFIHandle, getFlag, getInstanceEvalClass, getInstanceEvalClass, getInstanceVariable, getInstanceVariableList, getInstanceVariableNameList, getInstanceVariables, getInternalVariable, getInternalVariables, getJavaClass, getMarshalVariableList, getMetaClass, getMetaClass, getNativeHandle, getNativeTypeIndex, getObjectId, getRuntime, getSingletonClass, getSingletonClassClone, getSingletonClassCloneAndAttach, getSingletonClassCloneAndAttach, getType, getVariable, getVariableCount, getVariableList, getVariableNameList, hash, hash, hashyInspect, hasInstanceVariable, hasInstanceVariables, hasInternalVariable, hasVariables, id, infectBy, initialize, initialize_copy, inspect, inspect, inspectHashCode, instance_eval, instance_eval, instance_eval, instance_eval, instance_eval, instance_exec, instance_of_p, instance_variable_defined_p, instance_variable_get, instance_variable_set, instance_variables, isBuiltin, isClass, isFalse, isFrozen, isImmediate, isModule, isNil, isSpecialConst, isSpecialObject, isTaint, isTrue, isUntrusted, kind_of_p, makeMetaClass, makeMetaClass, makeMetaClassBootstrap, method, method, method, method_missing, methods, methods, nil_p, nonFixnumHashCode, nonFixnumHashCode, OBJ_INIT_COPY, objInitCopy, op_match, op_not_equal, op_not_match, private_methods, protected_methods, public_methods, rbInspect, remove_instance_variable, removeFinalizers, removeInstanceVariable, removeInternalVariable, respond_to_p, respond_to_p, respondsTo, respondsToMissing, respondsToMissing, send, send, send, send, send, setFFIHandle, setFlag, setFrozen, setInstanceVariable, setInternalVariable, setMetaClass, setNativeHandle, setTaint, setUntrusted, setVariable, singleton_method, singleton_method, singleton_method_added, singleton_method_removed, singleton_method_undefined, singleton_methods, singletonClass, specificEval, specificEval, specificEval, specificEval, syncVariables, syncVariables, taint, taint, tainted_p, testFrozen, testFrozen, to_a, to_a, trust, type, untaint, untrust, untrusted_p, validateInstanceVariable, validateInstanceVariable, validateInstanceVariable, variableTableContains, variableTableFastContains, variableTableFastFetch, variableTableFastStore, variableTableFetch, variableTableRemove, variableTableStore, variableTableSync, yieldUnder, yieldUnderMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.jruby.runtime.builtin.IRubyObject
checkStringType19, dup, marshalLiveVariables
-
Field Details
-
NUMERR_TYPE
public static final int NUMERR_TYPE- See Also:
-
NUMERR_NEGATIVE
public static final int NUMERR_NEGATIVE- See Also:
-
NUMERR_TOOLARGE
public static final int NUMERR_TOOLARGE- 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
Deprecated. -
signum
-
negate
Deprecated. -
negate
-
isNegative
Description copied from class:RubyNumericnum_negative_p- Overrides:
isNegativein classRubyNumeric
-
isPositive
Description copied from class:RubyNumericnum_positive_p- Overrides:
isPositivein classRubyNumeric
-
isNegativeNumber
- Overrides:
isNegativeNumberin classRubyNumeric
-
isPositiveNumber
- Overrides:
isPositiveNumberin classRubyNumeric
-
sqrt
rb_int_s_isqrt -
try_convert
-
sqrt
-
floorSqrt
public static final long floorSqrt(long x) -
floorSqrt
-
integer_p
int_int_p- Overrides:
integer_pin classRubyNumeric
-
upto
int_upto -
downto
int_downto -
times
-
timesSize
A times size method suitable for lambda method reference implementation ofRubyEnumerator.SizeFn.size(ThreadContext, IRubyObject, IRubyObject[])- See Also:
-
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 -
numToUint
Deprecated.UsenumToUint(ThreadContext, IRubyObject)instead.- Parameters:
val-- Returns:
- ""
-
numToUint
Simulate CRuby's rb_num_to_uint by returning a single long; the top 4 bytes will be the uint and the bottom four bytes will be the result code. SeeNUMERR_TYPE,NUMERR_NEGATIVE, andNUMERR_TOOLARGE.- Parameters:
val- the object to convert to a uint- Returns:
- the value and result code, with the top four bytes being the result code (zero if no error)
-
chr
-
ord
int_ord -
to_i
Deprecated. -
to_i
-
ceil
Description copied from class:RubyNumericMRI: num_ceil- Overrides:
ceilin classRubyNumeric
-
ceil
-
integerCeil
-
floor
Description copied from class:RubyNumericMRI: num_floor- Overrides:
floorin classRubyNumeric
-
floor
-
integerFloor
-
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
-
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
-
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 -
digits
-
digits
-
numerator
Description copied from class:RubyNumericnumeric_numerator- Overrides:
numeratorin classRubyNumeric
-
denominator
Description copied from class:RubyNumericnumeric_denominator- Overrides:
denominatorin classRubyNumeric
-
to_s
Deprecated.- Overrides:
to_sin classRubyBasicObject- Returns:
- ""
-
to_s
- Overrides:
to_sin classRubyBasicObject
-
to_s
Deprecated. -
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
Description copied from class:RubyNumericnum_cmp- Overrides:
op_cmpin classRubyNumeric
-
op_neg
-
op_and
-
op_or
-
op_xor
-
op_aref
-
op_aref_subclass
-
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
-
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
Deprecated. -
op_neg
Deprecated. -
op_aref
Deprecated. -
op_lshift
Deprecated. -
op_rshift
Deprecated. -
to_f
Deprecated. -
size
Deprecated. -
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
-
op_idiv
Deprecated.
-
numToUint(ThreadContext, IRubyObject)instead.