Package org.jruby
Class RubyBignum
java.lang.Object
org.jruby.RubyBasicObject
org.jruby.RubyObject
org.jruby.RubyNumeric
org.jruby.RubyInteger
org.jruby.RubyBignum
- All Implemented Interfaces:
Serializable,Cloneable,Comparable<IRubyObject>,InstanceVariables,InternalVariables,IRubyObject,CoreObjectType
- 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 BigIntegerstatic final BigIntegerstatic final BigIntegerstatic final BigIntegerstatic final BigIntegerstatic final BigIntegerstatic final BigIntegerFields inherited from class org.jruby.RubyInteger
NUMERR_NEGATIVE, NUMERR_TOOLARGE, NUMERR_TYPEFields 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabs()Deprecated.abs(ThreadContext context) rb_big_absasBigInteger(ThreadContext context) Return a BigInteger representation of this numerical valuedoubleasDouble(ThreadContext context) Return a double representation of this numerical valueintasInt(ThreadContext context) Returns the value of this numeric and a java int.longasLong(ThreadContext context) Return the value of this numeric as a 64-bit long.static doublebig2dbl(RubyBignum val) rb_big2dblstatic longbig2long(RubyBignum val) rb_big2longstatic longbig2ulong(RubyBignum value) rb_big2ulong This is here because for C extensions ulong can hold different values without throwing a RangeErrorstatic longbig2ulong(Ruby runtime, BigInteger big) static RubyIntegerbignorm(Ruby runtime, BigInteger bi) rb_big_normbit_length(ThreadContext context) ceil(ThreadContext context, IRubyObject arg) rb_big_ceilcoerce(ThreadContext context, IRubyObject other) num_coercefinal intcompareTo(IRubyObject other) Compares this Ruby object with another.convertToRational(ThreadContext context) denominator(ThreadContext context) numeric_denominatordigits(ThreadContext context, IRubyObject baseArg) rb_big_digitsdivmod(ThreadContext context, IRubyObject other) rb_big_divmodeql_p(ThreadContext context, IRubyObject other) rb_big_eqlbooleanThis override does not do a "checked" dispatch.even_p(ThreadContext context) fdivDouble(ThreadContext context, IRubyObject y) fdivFloat(ThreadContext context, RubyFloat y) fdivInt(ThreadContext context, RubyBignum y) static BigIntegerfix2big(RubyFixnum arg) rb_int2bigfloor(ThreadContext context, IRubyObject arg) rb_big_floorClass<?> Will return the Java interface that most closely can represent this object, when working through Java integration translations.This is overridden in the other concrete Java builtins to provide a fast way to determine what type they are.getValue()Getter for property value.hash(ThreadContext context) Will return the hash code of this object.inthashCode()This override does not do "checked" dispatch since Object usually has #hash defined.idiv(ThreadContext context, long other) idiv(ThreadContext context, IRubyObject other) rb_big_idivprotected booleanint_round_zero_p(ThreadContext context, int ndigits) booleanIs object immediate (def: Fixnum, Symbol, true, false, nil?).isNegative(ThreadContext context) num_negative_pisPositive(ThreadContext context) num_positive_pfinal booleanisZero(ThreadContext context) static BigIntegerlong2big(long arg) static voidmarshalTo(RubyBignum bignum, MarshalStream output) Deprecated, for removal: This API element is subject to removal in a future version.static voidmarshalTo(ThreadContext context, RubyOutputStream out, RubyBignum bignum, MarshalDumper output) modulo(ThreadContext context, IRubyObject other) num_modulonegate(ThreadContext context) static RubyIntegernewBignorm(Ruby runtime, double value) Return a Bignum or Fixnum (Integer) for the given value, or raise FloatDomainError if it is out of range.static RubyBignumReturn a Bignum for the given value, or raise FloatDomainError if it is out of range.static RubyBignumstatic RubyBignumstatic RubyBignumnewBignum(Ruby runtime, BigInteger value) nonzero_p(ThreadContext context) num_nonzero_pnumerator(ThreadContext context) numeric_numeratorodd_p(ThreadContext context) op_and(ThreadContext context, IRubyObject other) rb_big_andprotected IRubyObjectop_aref_subclass(ThreadContext context, IRubyObject other) rb_big_arefop_cmp(ThreadContext context, IRubyObject other) rb_big_cmpop_div(ThreadContext context, long other) op_div(ThreadContext context, IRubyObject other) rb_big_divop_equal(ThreadContext context, IRubyObject other) rb_big_eqop_ge(ThreadContext context, IRubyObject other) op_gt(ThreadContext context, IRubyObject other) op_le(ThreadContext context, IRubyObject other) op_lshift(ThreadContext context, long shift) op_lshift(ThreadContext context, IRubyObject other) rb_big_lshiftop_lt(ThreadContext context, IRubyObject other) final IRubyObjectop_minus(ThreadContext context, long other) final IRubyObjectop_minus(ThreadContext context, BigInteger other) op_minus(ThreadContext context, IRubyObject other) rb_big_minusop_mod(ThreadContext context, long other) op_mod(ThreadContext context, IRubyObject other) rb_big_modulofinal IRubyObjectop_mul(ThreadContext context, long other) op_mul(ThreadContext context, IRubyObject other) rb_big_mulop_neg(ThreadContext context) rb_big_negop_or(ThreadContext context, IRubyObject other) rb_big_orfinal IRubyObjectop_plus(ThreadContext context, long other) final IRubyObjectop_plus(ThreadContext context, BigInteger other) op_plus(ThreadContext context, IRubyObject other) rb_big_plusfinal IRubyObjectop_pow(ThreadContext context, long other) op_pow(ThreadContext context, IRubyObject other) rb_big_powop_rshift(ThreadContext context, long shift) op_rshift(ThreadContext context, IRubyObject other) rb_big_rshiftop_uminus(ThreadContext context) rb_big_uminusop_xor(ThreadContext context, IRubyObject other) rb_big_xorquo(ThreadContext context, IRubyObject otherArg) Deprecated.remainder(ThreadContext context, IRubyObject other) rb_big_remainderintsignum(ThreadContext context) singletonClass(ThreadContext context) Will either return the existing singleton class for this object, or create a new one and return that.size(ThreadContext context) rb_big_sizesqrt(ThreadContext context) to_f(ThreadContext context) rb_big_to_fto_s(IRubyObject[] args) Deprecated.to_s(ThreadContext context) to_s(ThreadContext context, IRubyObject arg0) static BigIntegertoBigInteger(double value) truncate(ThreadContext context, IRubyObject arg) rb_big_truncatestatic RubyNumericunmarshalFrom(UnmarshalStream input) Deprecated, for removal: This API element is subject to removal in a future version.static RubyNumericunmarshalFrom(ThreadContext context, RubyInputStream in, MarshalLoader input) zero_p(ThreadContext context) num_zero_pMethods inherited from class org.jruby.RubyInteger
allbits_p, anybits_p, ceil, ceil, chr, chr, convertToInteger, createIntegerClass, digits, div_div, downto, fdiv, floor, floor, floorSqrt, floorSqrt, gcd, gcdlcm, induced_from, int_half_p_half_down, int_half_p_half_even, int_half_p_half_up, int_round_half_down, int_round_half_even, int_round_half_up, integer_p, integerCeil, integerFloor, intPowTmp3, isNegativeNumber, isPositiveNumber, lcm, magnitude, negate, nobits_p, numToUint, numToUint, op_aref, op_aref, op_aref, op_idiv, op_lshift, op_neg, op_rshift, op_uminus, ord, pow, pow, pred, rationalize, round, round, round, round, round, roundShared, signum, singleCharByteList, singleCharString, singleCharUTF8ByteList, size, sqrt, succ, times, timesSize, to_f, to_i, to_i, to_r, to_s, to_s, toFloat, truncate, truncate, try_convert, uptoMethods inherited from class org.jruby.RubyNumeric
abs2, arg, asNumeric, callCoerced, callCoerced, callCoerced, callCoerced, checkInt, checkInt, coerce, coerceBin, coerceBin, coerceBit, coerceBit, coerceCmp, coerceCmp, coerceFailed, coerceRelOp, coerceRelOp, coerceRescue, compareWithZero, conjugate, convertToRational, createNumericClass, dbl_cmp, dbl2ival, dbl2num, div, doCoerce, dup, finite_p, fix2int, fix2int, fix2long, fixable, float2long, float2ulong, floatStep, floatStepSize, getBigIntegerValue, getCoerced, getDoubleValue, getIntValue, getLongValue, getRoundingMode, image, infinite_p, initialize_copy, int2fix, integer_p, intervalStepSize, isNegative, isPositive, isReal, isZero, negativeInt, negFixable, negFixable, newNumeric, 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, 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, finishObjectClass, 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, 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, getMarshalVariableList, getMetaClass, getMetaClass, getNativeHandle, getNativeTypeIndex, getObjectId, getRuntime, getSingletonClass, getSingletonClassClone, getSingletonClassCloneAndAttach, getSingletonClassCloneAndAttach, getType, getVariable, getVariableCount, getVariableList, getVariableNameList, 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, 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, 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
-
LONG_MAX
-
LONG_MAX_PLUS_ONE
-
LONG_MIN
-
LONG_MIN_MINUS_ONE
-
INTEGER_MAX
-
INTEGER_MIN
-
ULONG_MAX
-
-
Constructor Details
-
RubyBignum
-
-
Method Details
-
getNativeClassIndex
Description copied from class:RubyObjectThis is overridden in the other concrete Java builtins to provide a fast way to determine what type they are. Will generally return a value from org.jruby.runtime.ClassIndex- Specified by:
getNativeClassIndexin interfaceCoreObjectType- Overrides:
getNativeClassIndexin classRubyObject- Returns:
- the ClassIndex of the native type this object was constructed from
- See Also:
-
getJavaClass
Description copied from class:RubyBasicObjectWill return the Java interface that most closely can represent this object, when working through Java integration translations.- Specified by:
getJavaClassin interfaceIRubyObject- Overrides:
getJavaClassin classRubyBasicObject- Returns:
- the true Java class of this (Ruby) object
-
newBignum
-
newBignum
Return a Bignum for the given value, or raise FloatDomainError if it is out of range. Note this method may return Bignum that are in Fixnum range. -
toBigInteger
-
newBignorm
Return a Bignum or Fixnum (Integer) for the given value, or raise FloatDomainError if it is out of range. MRI: rb_dbl2big -
newBignum
-
newBignum
-
asBigInteger
Description copied from class:RubyNumericReturn a BigInteger representation of this numerical value- Overrides:
asBigIntegerin classRubyNumeric- Parameters:
context- the current thread context- Returns:
- a BigInteger
-
asDouble
Description copied from class:RubyNumericReturn a double representation of this numerical value- Overrides:
asDoublein classRubyNumeric- Parameters:
context- the current thread context- Returns:
- a double
-
asInt
Description copied from class:RubyNumericReturns the value of this numeric and a java int.- Overrides:
asIntin classRubyNumeric
-
asLong
Description copied from class:RubyNumericReturn the value of this numeric as a 64-bit long.- Overrides:
asLongin classRubyNumeric
-
singletonClass
Description copied from class:RubyBasicObjectWill either return the existing singleton class for this object, or create a new one and return that. For a few types a singleton class is not possible so it will throw an error.- Specified by:
singletonClassin interfaceIRubyObject- Overrides:
singletonClassin classRubyBasicObject- Parameters:
context- the current thread context- Returns:
- the singleton of this type
-
getValue
Getter for property value.- Returns:
- Value of property value.
-
signum
- Overrides:
signumin classRubyInteger
-
negate
- Overrides:
negatein classRubyInteger
-
bignorm
rb_big_norm -
big2long
rb_big2long -
big2ulong
rb_big2ulong This is here because for C extensions ulong can hold different values without throwing a RangeError -
big2ulong
-
big2dbl
rb_big2dbl -
fix2big
rb_int2big -
long2big
-
ceil
rb_big_ceil- Specified by:
ceilin classRubyInteger
-
floor
rb_big_floor- Specified by:
floorin classRubyInteger
-
truncate
rb_big_truncate- Specified by:
truncatein classRubyInteger
-
digits
rb_big_digits- Specified by:
digitsin classRubyInteger
-
to_s
Deprecated.rb_big_to_s -
to_s
- Overrides:
to_sin classRubyInteger
-
to_s
- Overrides:
to_sin classRubyInteger
-
coerce
Description copied from class:RubyNumericnum_coerce- Overrides:
coercein classRubyNumeric
-
op_uminus
rb_big_uminus- Specified by:
op_uminusin classRubyInteger
-
op_plus
rb_big_plus- Specified by:
op_plusin classRubyInteger
-
op_plus
- Overrides:
op_plusin classRubyInteger
-
op_plus
-
op_minus
rb_big_minus- Specified by:
op_minusin classRubyInteger
-
op_minus
- Overrides:
op_minusin classRubyInteger
-
op_minus
-
op_mul
rb_big_mul- Specified by:
op_mulin classRubyInteger
-
op_mul
- Overrides:
op_mulin classRubyInteger
-
op_div
rb_big_div- Specified by:
op_divin classRubyInteger
-
op_div
-
idiv
rb_big_idiv- Specified by:
idivin classRubyInteger
-
idiv
- Overrides:
idivin classRubyNumeric
-
divmod
rb_big_divmod- Overrides:
divmodin classRubyInteger
-
op_mod
rb_big_modulo- Specified by:
op_modin classRubyInteger
-
op_mod
- Overrides:
op_modin classRubyInteger
-
modulo
Description copied from class:RubyNumericnum_modulo- Overrides:
moduloin classRubyNumeric
-
remainder
rb_big_remainder- Overrides:
remainderin classRubyInteger
-
quo
Deprecated.MRI: rb_big_quo, formerly Deprecated since 10.0 since CRuby no longer has Bignum-specific quo logic.- Overrides:
quoin classRubyNumeric
-
op_pow
rb_big_pow- Specified by:
op_powin classRubyInteger
-
op_pow
-
op_and
rb_big_and- Specified by:
op_andin classRubyInteger
-
op_or
rb_big_or- Specified by:
op_orin classRubyInteger
-
bit_length
- Specified by:
bit_lengthin classRubyInteger
-
op_xor
rb_big_xor- Specified by:
op_xorin classRubyInteger
-
op_neg
rb_big_neg- Specified by:
op_negin classRubyInteger
-
op_lshift
rb_big_lshift- Specified by:
op_lshiftin classRubyInteger
-
op_lshift
- Overrides:
op_lshiftin classRubyInteger
-
op_rshift
rb_big_rshift- Specified by:
op_rshiftin classRubyInteger
-
op_rshift
- Overrides:
op_rshiftin classRubyInteger
-
odd_p
- Overrides:
odd_pin classRubyInteger
-
even_p
- Overrides:
even_pin classRubyInteger
-
op_aref_subclass
rb_big_aref- Specified by:
op_aref_subclassin classRubyInteger
-
op_gt
- Overrides:
op_gtin classRubyInteger
-
op_lt
- Overrides:
op_ltin classRubyInteger
-
op_ge
- Overrides:
op_gein classRubyInteger
-
op_le
- Overrides:
op_lein classRubyInteger
-
compareTo
Description copied from class:RubyBasicObjectCompares this Ruby object with another.- Specified by:
compareToin interfaceComparable<IRubyObject>- Overrides:
compareToin classRubyBasicObject- Parameters:
other- another IRubyObject- Returns:
- 0 if equal, < 0 if this is less than other, > 0 if this is greater than other
-
equals
Description copied from class:RubyObjectThis override does not do a "checked" dispatch.- Overrides:
equalsin classRubyObject- Parameters:
other- object to compare- Returns:
- true if equals
- See Also:
-
op_cmp
rb_big_cmp- Specified by:
op_cmpin classRubyInteger
-
op_equal
rb_big_eq- Specified by:
op_equalin interfaceIRubyObject- Specified by:
op_equalin classRubyInteger
-
eql_p
rb_big_eql- Overrides:
eql_pin classRubyNumeric
-
hash
Description copied from class:RubyBasicObjectWill return the hash code of this object. In comparison to MRI, this method will use the Java identity hash code instead of using rb_obj_id, since the usage of id in JRuby will incur the cost of some. ObjectSpace maintenance.- Overrides:
hashin classRubyBasicObject- Parameters:
context- the current thread context- Returns:
- the hash value
-
hashCode
public int hashCode()Description copied from class:RubyObjectThis override does not do "checked" dispatch since Object usually has #hash defined.- Overrides:
hashCodein classRubyObject- Returns:
- the hash code
- See Also:
-
to_f
rb_big_to_f- Specified by:
to_fin classRubyInteger
-
abs
Deprecated. -
abs
rb_big_abs- Specified by:
absin classRubyInteger
-
size
rb_big_size- Specified by:
sizein classRubyInteger
-
zero_p
Description copied from class:RubyNumericnum_zero_p- Specified by:
zero_pin classRubyInteger
-
isZero
- Overrides:
isZeroin classRubyNumeric
-
nonzero_p
Description copied from class:RubyNumericnum_nonzero_p- Overrides:
nonzero_pin classRubyNumeric
-
marshalTo
@Deprecated(since="10.0", forRemoval=true) public static void marshalTo(RubyBignum bignum, MarshalStream output) throws IOException Deprecated, for removal: This API element is subject to removal in a future version.- Throws:
IOException
-
marshalTo
public static void marshalTo(ThreadContext context, RubyOutputStream out, RubyBignum bignum, MarshalDumper output) -
unmarshalFrom
@Deprecated(since="10.0", forRemoval=true) public static RubyNumeric unmarshalFrom(UnmarshalStream input) throws IOException Deprecated, for removal: This API element is subject to removal in a future version.- Throws:
IOException
-
unmarshalFrom
public static RubyNumeric unmarshalFrom(ThreadContext context, RubyInputStream in, MarshalLoader input) -
fdivDouble
- Specified by:
fdivDoublein classRubyInteger
-
fdivInt
-
fdivFloat
-
isNegative
Description copied from class:RubyNumericnum_negative_p- Overrides:
isNegativein classRubyInteger
-
isPositive
Description copied from class:RubyNumericnum_positive_p- Overrides:
isPositivein classRubyInteger
-
int_round_zero_p
- Overrides:
int_round_zero_pin classRubyInteger
-
isImmediate
public boolean isImmediate()Description copied from class:RubyBasicObjectIs object immediate (def: Fixnum, Symbol, true, false, nil?).- Specified by:
isImmediatein interfaceIRubyObject- Overrides:
isImmediatein classRubyBasicObject- Returns:
- boolean
-
numerator
Description copied from class:RubyNumericnumeric_numerator- Overrides:
numeratorin classRubyInteger
-
denominator
Description copied from class:RubyNumericnumeric_denominator- Overrides:
denominatorin classRubyInteger
-
convertToRational
- Overrides:
convertToRationalin classRubyNumeric
-
sqrt
- Specified by:
sqrtin classRubyInteger
-