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.NumberTooLargeException
Nested classes/interfaces inherited from class org.jruby.RubyObject
RubyObject.Data
Nested classes/interfaces inherited from class org.jruby.RubyBasicObject
RubyBasicObject.Finalizer
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final int
Fields inherited from class org.jruby.RubyNumeric
DBL_EPSILON
Fields inherited from class org.jruby.RubyObject
IVAR_INSPECTING_OBJECT_ALLOCATOR, OBJECT_ALLOCATOR, REIFYING_OBJECT_ALLOCATOR
Fields 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, varTableStamp
Fields 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 IRubyObject
abs
(ThreadContext context) num_absallbits_p
(ThreadContext context, IRubyObject other) anybits_p
(ThreadContext context, IRubyObject other) abstract IRubyObject
bit_length
(ThreadContext context) ceil()
Deprecated.ceil
(ThreadContext context) MRI: num_ceilabstract IRubyObject
ceil
(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 RubyClass
createIntegerClass
(ThreadContext context, RubyClass Numeric) denominator
(ThreadContext context) numeric_denominatordigits
(ThreadContext context) abstract RubyArray
digits
(ThreadContext context, IRubyObject base) final IRubyObject
div_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 IRubyObject
fdivDouble
(ThreadContext context, IRubyObject y) floor()
Deprecated.floor
(ThreadContext context) MRI: num_floorabstract IRubyObject
floor
(ThreadContext context, IRubyObject arg) static final long
floorSqrt
(long x) static final BigInteger
gcd
(ThreadContext context, IRubyObject other) rb_gcdgcdlcm
(ThreadContext context, IRubyObject other) rb_gcdlcmabstract IRubyObject
idiv
(ThreadContext context, IRubyObject other) MRI: rb_int_idiv and overridesstatic IRubyObject
induced_from
(ThreadContext context, IRubyObject recv, IRubyObject other) Deprecated.protected static boolean
int_half_p_half_down
(ThreadContext context, RubyInteger num, RubyNumeric n, IRubyObject f) protected static boolean
int_half_p_half_even
(ThreadContext context, RubyInteger num, RubyNumeric n, IRubyObject f) protected static boolean
int_half_p_half_up
(ThreadContext context, RubyInteger num, RubyNumeric n, IRubyObject f) protected static long
int_round_half_down
(long x, long y) protected static long
int_round_half_even
(long x, long y) protected static long
int_round_half_up
(long x, long y) protected boolean
int_round_zero_p
(ThreadContext context, int ndigits) integer_p
(ThreadContext context) int_int_pprotected RubyNumeric
integerCeil
(ThreadContext context, RubyNumeric f) protected RubyNumeric
integerFloor
(ThreadContext context, RubyInteger f) protected IRubyObject
intPowTmp3
(ThreadContext context, RubyInteger y, RubyBignum m, boolean negaFlg) isNegative
(ThreadContext context) num_negative_pboolean
isNegativeNumber
(ThreadContext context) isPositive
(ThreadContext context) num_positive_pboolean
isPositiveNumber
(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 long
numToUint
(IRubyObject val) Deprecated.static long
numToUint
(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 IRubyObject
op_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 IRubyObject
op_aref_subclass
(ThreadContext context, IRubyObject index) abstract IRubyObject
op_cmp
(ThreadContext context, IRubyObject other) num_cmpabstract IRubyObject
op_div
(ThreadContext context, IRubyObject other) abstract IRubyObject
op_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 IRubyObject
op_idiv
(ThreadContext context, IRubyObject arg) Deprecated.op_le
(ThreadContext context, IRubyObject other) op_lshift
(IRubyObject other) Deprecated.op_lshift
(ThreadContext context, long other) abstract IRubyObject
op_lshift
(ThreadContext context, IRubyObject other) op_lt
(ThreadContext context, IRubyObject other) op_minus
(ThreadContext context, long other) abstract IRubyObject
op_minus
(ThreadContext context, IRubyObject other) op_mod
(ThreadContext context, long other) abstract IRubyObject
op_mod
(ThreadContext context, IRubyObject other) op_mul
(ThreadContext context, long other) abstract IRubyObject
op_mul
(ThreadContext context, IRubyObject other) op_neg()
Deprecated.abstract IRubyObject
op_neg
(ThreadContext context) abstract IRubyObject
op_or
(ThreadContext context, IRubyObject other) op_plus
(ThreadContext context, long other) abstract IRubyObject
op_plus
(ThreadContext context, IRubyObject other) abstract IRubyObject
op_pow
(ThreadContext context, IRubyObject other) op_rshift
(IRubyObject other) Deprecated.op_rshift
(ThreadContext context, long other) abstract IRubyObject
op_rshift
(ThreadContext context, IRubyObject other) Deprecated.abstract IRubyObject
op_uminus
(ThreadContext context) num_uminusabstract IRubyObject
op_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) int
signum()
Deprecated.int
signum
(ThreadContext context) static ByteList
singleCharByteList
(byte index) 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.static ByteList
singleCharUTF8ByteList
(byte index) Return a low ASCII single-character bytelist with UTF-8 encoding, using cached values.size()
Deprecated.abstract IRubyObject
size
(ThreadContext context) abstract IRubyObject
sqrt
(ThreadContext context) static IRubyObject
sqrt
(ThreadContext context, IRubyObject self, IRubyObject num) rb_int_s_isqrtsucc
(ThreadContext context) int_succtimes
(ThreadContext context, Block block) protected static IRubyObject
timesSize
(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 IRubyObject
to_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 RubyFloat
toFloat()
truncate()
Deprecated.truncate
(ThreadContext context) MRI: num_truncateabstract IRubyObject
truncate
(ThreadContext context, IRubyObject arg) static IRubyObject
try_convert
(ThreadContext context, IRubyObject self, IRubyObject num) upto
(ThreadContext context, IRubyObject to, Block block) int_uptoabstract IRubyObject
zero_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, toJava
Methods 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, toString
Methods 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, yieldUnder
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods 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:RubyBasicObject
Tries to convert this object to a Ruby Integer using the "to_int" method.- Specified by:
convertToInteger
in interfaceIRubyObject
- Overrides:
convertToInteger
in classRubyBasicObject
- Returns:
- an integer representation of this
-
toFloat
-
signum
Deprecated. -
signum
-
negate
Deprecated. -
negate
-
isNegative
Description copied from class:RubyNumeric
num_negative_p- Overrides:
isNegative
in classRubyNumeric
-
isPositive
Description copied from class:RubyNumeric
num_positive_p- Overrides:
isPositive
in classRubyNumeric
-
isNegativeNumber
- Overrides:
isNegativeNumber
in classRubyNumeric
-
isPositiveNumber
- Overrides:
isPositiveNumber
in 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_p
in 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:RubyNumeric
MRI: num_ceil- Overrides:
ceil
in classRubyNumeric
-
ceil
-
integerCeil
-
floor
Description copied from class:RubyNumeric
MRI: num_floor- Overrides:
floor
in classRubyNumeric
-
floor
-
integerFloor
-
truncate
Description copied from class:RubyNumeric
MRI: num_truncate- Overrides:
truncate
in classRubyNumeric
-
truncate
-
round
Description copied from class:RubyNumeric
MRI: num_round- Overrides:
round
in 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:RubyNumeric
num_fdiv- Overrides:
fdiv
in classRubyNumeric
-
fdivDouble
-
lcm
rb_lcm -
gcdlcm
rb_gcdlcm -
digits
-
digits
-
numerator
Description copied from class:RubyNumeric
numeric_numerator- Overrides:
numerator
in classRubyNumeric
-
denominator
Description copied from class:RubyNumeric
numeric_denominator- Overrides:
denominator
in classRubyNumeric
-
to_s
Deprecated.- Overrides:
to_s
in classRubyBasicObject
- Returns:
- ""
-
to_s
- Overrides:
to_s
in classRubyBasicObject
-
to_s
Deprecated. -
to_s
-
op_uminus
Description copied from class:RubyNumeric
num_uminus- Overrides:
op_uminus
in classRubyNumeric
-
op_plus
- Overrides:
op_plus
in classRubyNumeric
-
op_plus
-
op_minus
- Overrides:
op_minus
in classRubyNumeric
-
op_minus
-
op_mul
-
op_mul
-
idiv
Description copied from class:RubyNumeric
MRI: rb_int_idiv and overrides- Overrides:
idiv
in 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:RubyNumeric
num_abs- Overrides:
abs
in classRubyNumeric
-
magnitude
Description copied from class:RubyNumeric
num_abs/1.9- Overrides:
magnitude
in classRubyNumeric
-
op_equal
Description copied from class:RubyBasicObject
rb_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_equal
in interfaceIRubyObject
- Overrides:
op_equal
in classRubyBasicObject
-
op_cmp
Description copied from class:RubyNumeric
num_cmp- Overrides:
op_cmp
in 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:RubyNumeric
num_zero_p- Overrides:
zero_p
in classRubyNumeric
-
bit_length
-
op_gt
-
op_lt
-
op_ge
-
op_le
-
remainder
Description copied from class:RubyNumeric
num_remainder- Overrides:
remainder
in classRubyNumeric
-
divmod
Description copied from class:RubyNumeric
num_divmod- Overrides:
divmod
in 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:
round
in classRubyNumeric
-
ceil
Deprecated.- Overrides:
ceil
in classRubyNumeric
-
floor
Deprecated.- Overrides:
floor
in classRubyNumeric
-
truncate
Deprecated.Description copied from class:RubyNumeric
num_truncate- Overrides:
truncate
in classRubyNumeric
-
op_idiv
Deprecated.
-
numToUint(ThreadContext, IRubyObject)
instead.