Top Description Fields Constructors Methods
org.jruby

public Class RubyFixnum

extends RubyInteger
implements Constantizable, Appendable
Class Inheritance
All Implemented Interfaces
org.jruby.Appendable, org.jruby.compiler.Constantizable
Imports
java.math.BigInteger, org.jcodings.specific.USASCIIEncoding, org.jruby.api.Convert, .Create, .JRubyAPI, org.jruby.compiler.Constantizable, org.jruby.runtime.Block, .CallSite, .ClassIndex, .Helpers, .JavaSites, .Signature, .ThreadContext, org.jruby.runtime.builtin.IRubyObject, org.jruby.runtime.callsite.CachingCallSite, org.jruby.runtime.marshal.MarshalLoader, org.jruby.runtime.opto.OptoFactory, org.jruby.util.ConvertBytes, .StringSupport, org.jruby.util.cli.Options, org.jruby.util.io.RubyInputStream

Implementation of the Integer (Fixnum internal) class.

Field Summary

Modifier and TypeField and Description
private static final int
public static final int
public static final long
public static final long
public static final long
public static final long
private static final BigInteger
public static final long
public static final boolean
pack-priv final long
Inherited from org.jruby.RubyInteger:
NUMERR_NEGATIVENUMERR_TOOLARGENUMERR_TYPESINGLE_CHAR_ASCII8BIT_BYTELISTSSINGLE_CHAR_BYTESSINGLE_CHAR_USASCII_BYTELISTSSINGLE_CHAR_UTF8_BYTELISTS

Constructor Summary

AccessConstructor and Description
public
RubyFixnum(Ruby runtime)

public
RubyFixnum(Ruby runtime, long value)

private
RubyFixnum(RubyClass klazz, long value)

Method Summary

Modifier and TypeMethod and Description
public IRubyObject
abs(ThreadContext context)

Implements abstract org.jruby.RubyInteger.abs.

fix_abs

private static RubyInteger
addAsBignum(ThreadContext context, long value, long other)

private static RubyInteger
addAsBignum(ThreadContext context, long value, BigInteger other)

private IRubyObject
private static boolean
addOverflowed(long other, long value, long result)

public void
public BigInteger
asBigInteger(ThreadContext
the current thread context
context
)

Overrides org.jruby.RubyNumeric.asBigInteger.

Return a BigInteger representation of this numerical value

public double
asDouble(ThreadContext
the current thread context
context
)

Overrides org.jruby.RubyNumeric.asDouble.

Return a double representation of this numerical value

public int
asInt(ThreadContext context)

Overrides org.jruby.RubyNumeric.asInt.

Returns the value of this numeric and a java int.

public String
asJavaString()

Overrides org.jruby.RubyBasicObject.asJavaString.

Implements org.jruby.runtime.builtin.IRubyObject.asJavaString.

rb_to_id Will try to convert this object to a String using the Ruby "to_str" if the object isn't already a String.

public long
asLong(ThreadContext context)

Overrides org.jruby.RubyNumeric.asLong.

Return the value of this numeric as a 64-bit long.

public IRubyObject
private static RubyFixnum
cachedFixnum(Ruby runtime, long value)

public IRubyObject
ceil(ThreadContext context, IRubyObject arg)

Implements abstract org.jruby.RubyInteger.ceil.

rb_fix_ceil

private void
private IRubyObject
public final int
compareTo(IRubyObject
another IRubyObject
other
)

Overrides org.jruby.RubyBasicObject.compareTo.

Implements java.lang.Comparable.compareTo.

Compares this Ruby object with another.

private int
public Object
public RubyInteger
convertToInteger(String
conversion method to use e.g. "to_i"
method
)

Overrides org.jruby.RubyBasicObject.convertToInteger.

Implements org.jruby.runtime.builtin.IRubyObject.convertToInteger.

Tries to convert this object to a Ruby Integer using the supplied conversion method.

public RubyRational
public static RubyClass
public IRubyObject
denominator(ThreadContext context)

Overrides org.jruby.RubyInteger.denominator.

numeric_denominator

public RubyArray<T extends IRubyObject>
digits(ThreadContext context, IRubyObject baseArg)

Implements abstract org.jruby.RubyInteger.digits.

rb_fix_digits

public IRubyObject
divmod(ThreadContext context, IRubyObject other)

Overrides org.jruby.RubyInteger.divmod.

fix_divmod

private IRubyObject
public final boolean
eql(IRubyObject other)

Overrides org.jruby.RubyBasicObject.eql.

Implements org.jruby.runtime.builtin.IRubyObject.eql.

short circuit for Fixnum key comparison

public IRubyObject
equal_p(ThreadContext
the thread context
context
,
IRubyObject
to compare with
obj
)

Overrides org.jruby.RubyBasicObject.equal_p.

rb_obj_equal Will use Java identity equality.

public boolean
equals(Object
object to compare
other
)

Overrides org.jruby.RubyObject.equals.

This override does not do a "checked" dispatch.

public RubyBoolean
public final boolean
public IRubyObject
public static RubyFixnum
five(Ruby runtime)

private static IRubyObject
private static long
fixHash(Ruby runtime, long value)

private static boolean

Returns:

true if the value is in fixnum range, false otherwise
fixnumable
(long
the value in question
value
)

Determine whether the given long value is in fixnum range.

private RubyNumeric
fixPowInverted(ThreadContext context, long minusb)

public IRubyObject
floor(ThreadContext context, IRubyObject arg)

Implements abstract org.jruby.RubyInteger.floor.

rb_fix_floor

public static RubyFixnum
four(Ruby runtime)

public double
getDoubleValue()

Overrides org.jruby.RubyNumeric.getDoubleValue.

Deprecated since 10.0.

public Class<?>
getJavaClass()

Overrides org.jruby.RubyBasicObject.getJavaClass.

Implements org.jruby.runtime.builtin.IRubyObject.getJavaClass.

Will return the Java interface that most closely can represent this object, when working through Java integration translations.

public long
getLongValue()

Overrides org.jruby.RubyNumeric.getLongValue.

Deprecated since 10.0.

Return the value of this numeric as a 64-bit long.

public ClassIndex
getNativeClassIndex()

Overrides org.jruby.RubyObject.getNativeClassIndex.

Implements org.jruby.runtime.marshal.CoreObjectType.getNativeClassIndex.

This is overridden in the other concrete Java builtins to provide a fast way to determine what type they are.

public long

Returns:

the long value
getValue
()

When you know you are working directly with a Fixnum you can get the long value it represents without using org.jruby.RubyNumeric#asLong(ThreadContext).

public RubyFixnum
hash(ThreadContext
the current thread context
context
)

Overrides org.jruby.RubyBasicObject.hash.

Will return the hash code of this object.

public final int
hashCode()

Overrides org.jruby.RubyObject.hashCode.

This override does not do "checked" dispatch since Object usually has #hash defined.

public IRubyObject
id()

Overrides org.jruby.RubyBasicObject.id.

Implements org.jruby.runtime.builtin.IRubyObject.id.

rb_obj_id Return the internal id of an object.

public IRubyObject
idiv(ThreadContext context, IRubyObject other)

Implements abstract org.jruby.RubyInteger.idiv.

fix_div here is terrible MRI gotcha: 1.div 3.0$ -> 0 1 / 3.0 $ -> 0.3333333333333333 MRI is also able to do it in one place by looking at current frame in rb_num_coerce_bin: rb_funcall(x, ruby_frame->orig_func, 1, y); also note that RubyFloat doesn't override Numeric.div

public IRubyObject
idiv(ThreadContext context, long other)

Overrides org.jruby.RubyNumeric.idiv.

public IRubyObject
idiv(ThreadContext context, IRubyObject other, String method)
Deprecated

public IRubyObject
idiv(ThreadContext context, IRubyObject other, CallSite site)

public IRubyObject
idiv(ThreadContext context, long y, String method)
Deprecated

private RubyInteger
idivLong(ThreadContext context, long x, long y)

public static IRubyObject
induced_from(IRubyObject recv, IRubyObject other)
Deprecated

protected boolean
protected IRubyObject
intPowTmp1(ThreadContext context, RubyInteger y, long mm, boolean negaFlg)

protected IRubyObject
intPowTmp2(ThreadContext context, IRubyObject y, final long mm, boolean negaFlg)
Deprecated

pack-priv IRubyObject
intPowTmp2(ThreadContext context, RubyInteger y, final long mm, boolean negaFlg)

public boolean
isImmediate()

Overrides org.jruby.RubyBasicObject.isImmediate.

Implements org.jruby.runtime.builtin.IRubyObject.isImmediate.

Is object immediate (def: Fixnum, Symbol, true, false, nil?).

private static boolean
isInCacheRange(long value)

public IRubyObject
isNegative(ThreadContext context)

Overrides org.jruby.RubyInteger.isNegative.

num_negative_p

pack-priv final boolean
public IRubyObject
isPositive(ThreadContext context)

Overrides org.jruby.RubyInteger.isPositive.

num_positive_p

public final boolean
private RubyString
longToString(ThreadContext context, long value, int base)

private RubyInteger
lshift(ThreadContext context, final long width)

public IRubyObject
public static RubyFixnum
minus_one(Ruby runtime)

public IRubyObject
modulo(ThreadContext context, IRubyObject other)

Overrides org.jruby.RubyNumeric.modulo.

num_modulo

pack-priv IRubyObject
modulo(ThreadContext context, long other)

Overrides org.jruby.RubyNumeric.modulo.

private IRubyObject
private IRubyObject
moduloFixnum(ThreadContext context, long other)

private static RubyFixnum
private static RubyInteger
multiplyAsBignum(ThreadContext context, long value, long other)

private IRubyObject
public RubyInteger
private static RubyInteger
negate(ThreadContext context, final long value)

public static RubyFixnum
newFixnum(Ruby runtime, long value)

public static RubyFixnum
newFixnum(Ruby runtime, int value)

public final RubyFixnum
newFixnum(long newValue)
Deprecated

public IRubyObject
nonzero_p(ThreadContext context)

Overrides org.jruby.RubyNumeric.nonzero_p.

num_nonzero_p

public IRubyObject
numerator(ThreadContext context)

Overrides org.jruby.RubyInteger.numerator.

numeric_numerator

public RubyBoolean
public static RubyFixnum
one(Ruby runtime)

public IRubyObject
op_and(ThreadContext context, IRubyObject other)

Implements abstract org.jruby.RubyInteger.op_and.

fix_and

public IRubyObject
op_and(ThreadContext context, long other)

protected IRubyObject
op_aref_subclass(ThreadContext context, IRubyObject other)

Implements abstract org.jruby.RubyInteger.op_aref_subclass.

rb_fix_aref

public IRubyObject
op_cmp(ThreadContext context, IRubyObject other)

Implements abstract org.jruby.RubyInteger.op_cmp.

fix_cmp

public IRubyObject
op_cmp(ThreadContext context, long other)

public IRubyObject
op_cmp(ThreadContext context, double other)

public IRubyObject
op_div(ThreadContext context, IRubyObject other)

Implements abstract org.jruby.RubyInteger.op_div.

public IRubyObject
op_div(ThreadContext context, long other)

public IRubyObject
public IRubyObject
op_equal(ThreadContext context, long other)

public IRubyObject
op_equal(ThreadContext context, double other)

public boolean
op_equal_boolean(ThreadContext context, long other)

private IRubyObject
public IRubyObject
public IRubyObject
op_ge(ThreadContext context, long other)

public boolean
op_ge_boolean(ThreadContext context, long other)

private IRubyObject
public IRubyObject
public IRubyObject
op_gt(ThreadContext context, long other)

public boolean
op_gt_boolean(ThreadContext context, long other)

private IRubyObject
public IRubyObject
public IRubyObject
op_le(ThreadContext context, long other)

public boolean
op_le_boolean(ThreadContext context, long other)

private IRubyObject
public IRubyObject
op_lshift(ThreadContext context, IRubyObject other)

Implements abstract org.jruby.RubyInteger.op_lshift.

fix_lshift

public RubyInteger
op_lshift(ThreadContext context, final long width)

Overrides org.jruby.RubyInteger.op_lshift.

public IRubyObject
op_lshift(long width)
Deprecated

public IRubyObject
public IRubyObject
op_lt(ThreadContext context, long other)

public boolean
op_lt_boolean(ThreadContext context, long other)

private IRubyObject
public IRubyObject
op_minus(ThreadContext context, IRubyObject other)

Implements abstract org.jruby.RubyInteger.op_minus.

fix_minus

public IRubyObject
op_minus(ThreadContext context, long other)

Overrides org.jruby.RubyInteger.op_minus.

public IRubyObject
op_minus(ThreadContext context, double other)

public IRubyObject

Returns:

RubyInteger
op_minus_one
(ThreadContext context)

public IRubyObject

Returns:

RubyInteger
op_minus_two
(ThreadContext context)

public IRubyObject
op_mod(ThreadContext context, IRubyObject other)

Implements abstract org.jruby.RubyInteger.op_mod.

fix_mod

public IRubyObject
op_mod(ThreadContext context, long other)

Overrides org.jruby.RubyInteger.op_mod.

public IRubyObject
op_mul(ThreadContext context, IRubyObject other)

Implements abstract org.jruby.RubyInteger.op_mul.

fix_mul

public IRubyObject
op_mul(ThreadContext context, long other)

Overrides org.jruby.RubyInteger.op_mul.

public IRubyObject
op_mul(ThreadContext context, double other)

public IRubyObject
op_neg(ThreadContext context)

Implements abstract org.jruby.RubyInteger.op_neg.

fix_rev

public IRubyObject
op_not_equal(ThreadContext
thread context
context
,
IRubyObject
other object
other
)

Overrides org.jruby.RubyBasicObject.op_not_equal.

fix_not_equal

public IRubyObject
op_not_equal(ThreadContext context, long other)

public IRubyObject
op_not_equal(ThreadContext context, double other)

public IRubyObject
op_or(ThreadContext context, IRubyObject other)

Implements abstract org.jruby.RubyInteger.op_or.

fix_or

public IRubyObject
op_or(ThreadContext context, long other)

public IRubyObject
op_plus(ThreadContext context, IRubyObject other)

Implements abstract org.jruby.RubyInteger.op_plus.

fix_plus

public IRubyObject
op_plus(ThreadContext context, long other)

Overrides org.jruby.RubyInteger.op_plus.

public IRubyObject
op_plus(ThreadContext context, double other)

public IRubyObject
public IRubyObject
public IRubyObject
op_pow(ThreadContext context, IRubyObject other)

Implements abstract org.jruby.RubyInteger.op_pow.

fix_pow

public IRubyObject
op_pow(ThreadContext context, long other)

public IRubyObject
op_rshift(ThreadContext context, IRubyObject other)

Implements abstract org.jruby.RubyInteger.op_rshift.

fix_rshift

public RubyInteger
op_rshift(ThreadContext context, final long width)

Overrides org.jruby.RubyInteger.op_rshift.

public IRubyObject
op_rshift(long width)
Deprecated

public IRubyObject
op_uminus(ThreadContext context)

Implements abstract org.jruby.RubyInteger.op_uminus.

fix_uminus

public IRubyObject
op_xor(ThreadContext context, IRubyObject other)

Implements abstract org.jruby.RubyInteger.op_xor.

fix_xor

public IRubyObject
op_xor(ThreadContext context, long other)

private RubyNumeric
private IRubyObject
public IRubyObject
public IRubyObject
private RubyFixnum
rshift(ThreadContext context, final long width)

public int
public RubyClass
singletonClass(ThreadContext
the current thread context
context
)

Overrides org.jruby.RubyBasicObject.singletonClass.

Overrides default org.jruby.runtime.builtin.IRubyObject.singletonClass.

Will either return the existing singleton class for this object, or create a new one and return that.

private static JavaSites.FixnumSites
sites(ThreadContext context)

Hides org.jruby.RubyInteger.sites.

Retrieve the call sites for this class.

public IRubyObject
size(ThreadContext context)

Implements abstract org.jruby.RubyInteger.size.

fix_size

public IRubyObject
sqrt(ThreadContext context)

Implements abstract org.jruby.RubyInteger.sqrt.

private RubyInteger
subtractAsBignum(ThreadContext context, long other)

private RubyInteger
private IRubyObject
public IRubyObject
succ(ThreadContext context)

Overrides org.jruby.RubyInteger.succ.

int_succ

public IRubyObject
taint(ThreadContext context)

Overrides org.jruby.RubyBasicObject.taint.

Deprecated

public static RubyFixnum
three(Ruby runtime)

public IRubyObject
public IRubyObject
to_f(ThreadContext context)

Implements abstract org.jruby.RubyInteger.to_f.

fix_to_f

public IRubyObject
to_f()

Overrides org.jruby.RubyInteger.to_f.

Deprecated since 10.0.

public RubyString
to_s(IRubyObject[] args)
Deprecated since 10.0.

fix_to_s

public RubyString
public RubyString
public IRubyObject
to_sym()
Deprecated

fix_to_sym

public IRubyObject
truncate(ThreadContext context, IRubyObject arg)

Implements abstract org.jruby.RubyInteger.truncate.

rb_fix_truncate

public static RubyFixnum
two(Ruby runtime)

public static RubyFixnum
unmarshalFrom(UnmarshalStream input)
Deprecated for removal since 10.0.

public static RubyFixnum
public static RubyFixnum
zero(Ruby runtime)

public IRubyObject
zero_p()
Deprecated

public IRubyObject
zero_p(ThreadContext context)

Implements abstract org.jruby.RubyInteger.zero_p.

fix_zero_p

Inherited from org.jruby.RubyInteger:
allbits_panybits_pceilceilchrchrconvertToIntegercreateIntegerClassdigitsdiv_divdowntoduckUptofdivfixnumUptofloorfloorfloorSqrtfloorSqrtgcdgcdlcmgenerateMaskinduced_fromint_half_p_half_downint_half_p_half_evenint_half_p_half_upint_round_half_downint_round_half_evenint_round_half_upinteger_pintegerCeilintegerFloorintPowTmp3intValueisNegativeNumberisOneisPositiveNumberlcmnegatenobits_pnumToUintnumToUintop_arefop_arefop_arefop_idivop_lshiftop_negop_rshiftop_uminusordpowpowrationalizeroundroundroundroundroundroundSharedsignumsingleCharASCII8BITByteListsingleCharByteListsingleCharStringsingleCharUSASCIIByteListsingleCharUTF8ByteListsizesqrttimesSizeto_ito_ito_rto_sto_stoFloattoIntegertruncatetruncatetry_convertupto