public class RubyNumeric extends RubyObject
Modifier and Type | Class and Description |
---|---|
static class |
RubyNumeric.InvalidIntegerException |
static class |
RubyNumeric.NumberTooLargeException |
RubyObject.Data
RubyBasicObject.Finalizer
Modifier and Type | Field and Description |
---|---|
static double |
DBL_EPSILON |
protected static ObjectAllocator |
NUMERIC_ALLOCATOR |
FIELD_ALLOCATED_CLASSES, FIELD_ALLOCATORS, IVAR_INSPECTING_OBJECT_ALLOCATOR, OBJECT_ALLOCATOR, OBJECT_VAR0_ALLOCATOR, OBJECT_VAR1_ALLOCATOR, OBJECT_VAR2_ALLOCATOR, OBJECT_VAR3_ALLOCATOR, OBJECT_VAR4_ALLOCATOR, OBJECT_VAR5_ALLOCATOR, OBJECT_VAR6_ALLOCATOR, OBJECT_VAR7_ALLOCATOR, OBJECT_VAR8_ALLOCATOR, OBJECT_VAR9_ALLOCATOR, REIFYING_OBJECT_ALLOCATOR
ALL_F, BASICOBJECT_ALLOCATOR, COMPARE_BY_IDENTITY_F, ERR_INSECURE_SET_INST_VAR, FALSE_F, FL_USHIFT, flags, FROZEN_F, metaClass, NEVER, NIL_F, STAMP_OFFSET, TAINTED_F, UNDEF, UNTRUSTED_F, USER0_F, USER1_F, USER2_F, USER3_F, USER4_F, USER5_F, USER6_F, USER7_F, USER8_F, VAR_TABLE_OFFSET, varTable, varTableStamp
NULL_ARRAY
Constructor and Description |
---|
RubyNumeric(RubyClass metaClass) |
RubyNumeric(Ruby runtime,
RubyClass metaClass) |
RubyNumeric(Ruby runtime,
RubyClass metaClass,
boolean useObjectSpace) |
RubyNumeric(Ruby runtime,
RubyClass metaClass,
boolean useObjectSpace,
boolean canBeTainted)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
IRubyObject |
abs(ThreadContext context)
num_abs
|
IRubyObject |
abs2(ThreadContext context)
numeric_abs2
|
IRubyObject |
arg(ThreadContext context)
numeric_arg
|
RubyNumeric |
asNumeric() |
IRubyObject |
callCoerced(ThreadContext context,
String method,
IRubyObject other) |
protected IRubyObject |
callCoerced(ThreadContext context,
String method,
IRubyObject other,
boolean err) |
IRubyObject |
ceil()
num_ceil
|
static void |
checkInt(IRubyObject arg,
long num)
check_int
|
IRubyObject |
coerce(IRubyObject other)
num_coerce
|
protected IRubyObject |
coerceBin(ThreadContext context,
String method,
IRubyObject other)
rb_num_coerce_bin
coercion taking two arguments
|
protected IRubyObject |
coerceBody(ThreadContext context,
IRubyObject other)
coerce_body
|
protected IRubyObject |
coerceCmp(ThreadContext context,
String method,
IRubyObject other)
rb_num_coerce_cmp
coercion used for comparisons
|
protected IRubyObject |
coerceRelOp(ThreadContext context,
String method,
IRubyObject other)
rb_num_coerce_relop
coercion used for relative operators
|
IRubyObject |
conjugate(ThreadContext context)
numeric_real
|
static RubyClass |
createNumericClass(Ruby runtime) |
static IRubyObject |
dbl_cmp(Ruby runtime,
double a,
double b)
rb_dbl_cmp (numeric.c)
|
static IRubyObject |
dbl2num(Ruby runtime,
double val)
rb_dbl2big + LONG2FIX at once (numeric.c)
|
IRubyObject |
denominator(ThreadContext context)
num_denominator
|
IRubyObject |
div(ThreadContext context,
IRubyObject other)
num_div
|
IRubyObject |
div19(ThreadContext context,
IRubyObject other)
num_div
|
IRubyObject |
divmod(ThreadContext context,
IRubyObject other)
num_divmod
|
IRubyObject |
divmod19(ThreadContext context,
IRubyObject other)
num_divmod
|
protected RubyArray |
doCoerce(ThreadContext context,
IRubyObject other,
boolean err)
do_coerce
|
IRubyObject |
eql_p(ThreadContext context,
IRubyObject other)
num_eql
|
IRubyObject |
fdiv(ThreadContext context,
IRubyObject other)
num_fdiv (1.9)
|
static int |
fix2int(IRubyObject arg) |
static int |
fix2int(RubyFixnum arg) |
static long |
fix2long(IRubyObject arg) |
protected static void |
floatStep(ThreadContext context,
Ruby runtime,
IRubyObject from,
IRubyObject to,
IRubyObject step,
Block block) |
IRubyObject |
floor()
num_floor
|
BigInteger |
getBigIntegerValue() |
protected IRubyObject[] |
getCoerced(ThreadContext context,
IRubyObject other,
boolean error)
Numeric methods.
|
double |
getDoubleValue() |
long |
getLongValue() |
IRubyObject |
image(ThreadContext context)
numeric_image
|
IRubyObject |
initialize_copy(IRubyObject arg)
num_init_copy
|
static RubyNumeric |
int2fix(Ruby runtime,
long val) |
IRubyObject |
integer_p()
num_int_p
|
IRubyObject |
magnitude(ThreadContext context)
num_abs/1.9
|
IRubyObject |
modulo(ThreadContext context,
IRubyObject other)
num_modulo
|
IRubyObject |
modulo19(ThreadContext context,
IRubyObject other)
num_modulo
|
static RubyNumeric |
newNumeric(Ruby runtime) |
IRubyObject |
nonzero_p(ThreadContext context)
num_nonzero_p
|
IRubyObject |
num_imaginary(ThreadContext context)
num_imaginary
|
static byte |
num2chr(IRubyObject arg)
NUM2CHR
|
static double |
num2dbl(IRubyObject arg)
rb_num2dbl and NUM2DBL
|
static IRubyObject |
num2fix(IRubyObject val)
rb_num2fix
|
static int |
num2int(IRubyObject arg)
rb_num2int, NUM2INT
|
static long |
num2long(IRubyObject arg)
rb_num2long and FIX2LONG (numeric.c)
|
IRubyObject |
numerator(ThreadContext context)
num_numerator
|
IRubyObject |
op_cmp(IRubyObject other)
num_cmp
|
protected IRubyObject |
op_num_equal(ThreadContext context,
IRubyObject other)
num_equal, doesn't override RubyObject.op_equal
|
IRubyObject |
op_uminus(ThreadContext context)
num_uminus
|
IRubyObject |
op_uplus()
num_uplus
|
IRubyObject |
polar(ThreadContext context)
numeric_polar
|
IRubyObject |
quo_19(ThreadContext context,
IRubyObject other)
num_quo (1.9)
|
IRubyObject |
quo(ThreadContext context,
IRubyObject other)
num_quo (1.8)
quo and fdiv in 1.8 just invokes "/"
|
IRubyObject |
real(ThreadContext context)
numeric_real
|
IRubyObject |
rect(ThreadContext context)
numeric_rect
|
IRubyObject |
remainder(ThreadContext context,
IRubyObject dividend)
num_remainder
|
IRubyObject |
round()
num_round
|
IRubyObject |
sadded(IRubyObject name)
num_sadded
|
IRubyObject |
scalar_p()
num_real_p
|
IRubyObject |
step(ThreadContext context,
IRubyObject arg0,
Block block) |
IRubyObject |
step(ThreadContext context,
IRubyObject to,
IRubyObject step,
Block block) |
static RubyFloat |
str2fnum(Ruby runtime,
RubyString arg) |
static RubyFloat |
str2fnum(Ruby runtime,
RubyString arg,
boolean strict)
Converts a string representation of a floating-point number to the
numeric value.
|
static RubyFloat |
str2fnum19(Ruby runtime,
RubyString arg,
boolean strict) |
static RubyInteger |
str2inum(Ruby runtime,
RubyString str,
int base) |
static RubyInteger |
str2inum(Ruby runtime,
RubyString str,
int base,
boolean strict)
Converts a string representation of an integer to the integer value.
|
IRubyObject |
to_c(ThreadContext context)
numeric_to_c
|
IRubyObject |
to_int(ThreadContext context)
num_to_int
|
Object |
toJava(Class target)
Convert the object to the specified Java class, if possible.
|
IRubyObject |
truncate()
num_truncate
|
IRubyObject |
zero_p(ThreadContext context)
num_zero_p
|
attachToObjectSpace, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, convertToType, createObjectClass, eqlInternal, equalInternal, equals, getNativeTypeIndex, hashCode, initialize, initialize, inspect, op_eqq, puts, specificEval, toString
addFinalizer, anyToString, asJavaString, asString, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callSuper, checkArrayType, checkCallMethod, checkFrozen, checkStringType, checkStringType19, compareTo, convertToArray, convertToFloat, convertToHash, convertToInteger, convertToInteger, convertToInteger, convertToString, copyInstanceVariablesInto, copySpecialInstanceVariables, createBasicObjectClass, dataGetStruct, dataGetStructChecked, dataWrapStruct, display, dup, ensureInstanceVariablesSettable, eql_p, eql, 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, getNativeHandle, getObjectId, getRuntime, getSingletonClass, getSingletonClassClone, getType, getVariable, getVariableCount, getVariableList, getVariableNameList, hash, hashyInspect, hasInstanceVariable, hasInternalVariable, hasVariables, id_deprecated, id, infectBy, 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, isTaint, isTrue, isUntrusted, kind_of_p, makeMetaClass, method_missing19, method, method19, methods, methods, methods19, nil_p, op_cmp, op_equal_19, op_equal, op_match, op_match19, op_not_equal, op_not_match, op_not, private_methods, private_methods19, protected_methods, protected_methods19, public_methods, public_methods19, rbClone, remove_instance_variable, removeFinalizers, removeInstanceVariable, removeInternalVariable, 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_added19, singleton_method_removed19, singleton_method_undefined19, singleton_methods, singleton_methods19, specificEval, specificEval, specificEval, specificEval, syncVariables, syncVariables, taint, taint, tainted_p, testFrozen, testFrozen, to_a, to_s, trust, type_deprecated, type, untaint, untrust, untrusted_p, validateInstanceVariable, variableTableContains, variableTableFastContains, variableTableFastFetch, variableTableFastStore, variableTableFetch, variableTableRemove, variableTableStore, variableTableSync, yieldUnder, yieldUnder
protected static final ObjectAllocator NUMERIC_ALLOCATOR
public static final double DBL_EPSILON
public RubyNumeric(RubyClass metaClass)
@Deprecated public RubyNumeric(Ruby runtime, RubyClass metaClass, boolean useObjectSpace, boolean canBeTainted)
public double getDoubleValue()
public long getLongValue()
public BigInteger getBigIntegerValue()
public static RubyNumeric newNumeric(Ruby runtime)
public static int num2int(IRubyObject arg)
public static void checkInt(IRubyObject arg, long num)
public static byte num2chr(IRubyObject arg)
public static long num2long(IRubyObject arg)
public static IRubyObject dbl2num(Ruby runtime, double val)
public static double num2dbl(IRubyObject arg)
public static IRubyObject dbl_cmp(Ruby runtime, double a, double b)
public static long fix2long(IRubyObject arg)
public static int fix2int(IRubyObject arg)
public static int fix2int(RubyFixnum arg)
public static RubyInteger str2inum(Ruby runtime, RubyString str, int base)
public static RubyNumeric int2fix(Ruby runtime, long val)
public static IRubyObject num2fix(IRubyObject val)
public static RubyInteger str2inum(Ruby runtime, RubyString str, int base, boolean strict)
base
is zero, strings that begin with '0[xX]',
'0[bB]', or '0' (optionally preceded by a sign) will be treated as hex,
binary, or octal numbers, respectively. If a non-zero base is given,
only the prefix (if any) that is appropriate to that base will be
parsed correctly. For example, if the base is zero or 16, the string
"0xff" will be converted to 256, but if the base is 10, it will come out
as zero, since 'x' is not a valid decimal digit. If the string fails
to parse as a number, zero is returned.runtime
- the ruby runtimestr
- the string to be convertedbase
- the expected base of the number (for example, 2, 8, 10, 16),
or 0 if the method should determine the base automatically
(defaults to 10). Values 0 and 2-36 are permitted. Any other
value will result in an ArgumentError.strict
- if true, enforce the strict criteria for String encoding of
numeric values, as required by Integer('n'), and raise an
exception when those criteria are not met. Otherwise, allow
lax expression of values, as permitted by String#to_i, and
return a value in almost all cases (excepting illegal radix).
TODO: describe the rules/criteriapublic static RubyFloat str2fnum(Ruby runtime, RubyString arg)
public static RubyFloat str2fnum(Ruby runtime, RubyString arg, boolean strict)
runtime
- the ruby runtimearg
- the string to be convertedstrict
- if true, enforce the strict criteria for String encoding of
numeric values, as required by Float('n'), and raise an
exception when those criteria are not met. Otherwise, allow
lax expression of values, as permitted by String#to_f, and
return a value in all cases.
TODO: describe the rules/criteriapublic static RubyFloat str2fnum19(Ruby runtime, RubyString arg, boolean strict)
protected IRubyObject[] getCoerced(ThreadContext context, IRubyObject other, boolean error)
protected IRubyObject callCoerced(ThreadContext context, String method, IRubyObject other, boolean err)
public IRubyObject callCoerced(ThreadContext context, String method, IRubyObject other)
protected final IRubyObject coerceBody(ThreadContext context, IRubyObject other)
protected final RubyArray doCoerce(ThreadContext context, IRubyObject other, boolean err)
protected final IRubyObject coerceBin(ThreadContext context, String method, IRubyObject other)
protected final IRubyObject coerceCmp(ThreadContext context, String method, IRubyObject other)
protected final IRubyObject coerceRelOp(ThreadContext context, String method, IRubyObject other)
public RubyNumeric asNumeric()
public IRubyObject sadded(IRubyObject name)
public IRubyObject initialize_copy(IRubyObject arg)
initialize_copy
in class RubyBasicObject
public IRubyObject coerce(IRubyObject other)
public IRubyObject op_uplus()
public IRubyObject num_imaginary(ThreadContext context)
public IRubyObject op_uminus(ThreadContext context)
public IRubyObject op_cmp(IRubyObject other)
public IRubyObject eql_p(ThreadContext context, IRubyObject other)
public IRubyObject quo(ThreadContext context, IRubyObject other)
public IRubyObject quo_19(ThreadContext context, IRubyObject other)
public IRubyObject div(ThreadContext context, IRubyObject other)
public IRubyObject div19(ThreadContext context, IRubyObject other)
public IRubyObject divmod(ThreadContext context, IRubyObject other)
public IRubyObject divmod19(ThreadContext context, IRubyObject other)
public IRubyObject fdiv(ThreadContext context, IRubyObject other)
public IRubyObject modulo(ThreadContext context, IRubyObject other)
public IRubyObject modulo19(ThreadContext context, IRubyObject other)
public IRubyObject remainder(ThreadContext context, IRubyObject dividend)
public IRubyObject abs(ThreadContext context)
public IRubyObject magnitude(ThreadContext context)
public IRubyObject to_int(ThreadContext context)
public IRubyObject scalar_p()
public IRubyObject integer_p()
public IRubyObject zero_p(ThreadContext context)
public IRubyObject nonzero_p(ThreadContext context)
public IRubyObject floor()
public IRubyObject ceil()
public IRubyObject round()
public IRubyObject truncate()
public IRubyObject step(ThreadContext context, IRubyObject arg0, Block block)
public IRubyObject step(ThreadContext context, IRubyObject to, IRubyObject step, Block block)
protected static void floatStep(ThreadContext context, Ruby runtime, IRubyObject from, IRubyObject to, IRubyObject step, Block block)
protected final IRubyObject op_num_equal(ThreadContext context, IRubyObject other)
public IRubyObject numerator(ThreadContext context)
public IRubyObject denominator(ThreadContext context)
public IRubyObject to_c(ThreadContext context)
public IRubyObject real(ThreadContext context)
public IRubyObject image(ThreadContext context)
public IRubyObject abs2(ThreadContext context)
public IRubyObject arg(ThreadContext context)
public IRubyObject rect(ThreadContext context)
public IRubyObject polar(ThreadContext context)
public IRubyObject conjugate(ThreadContext context)
public Object toJava(Class target)
IRubyObject
toJava
in interface IRubyObject
toJava
in class RubyBasicObject
target
- The target type to which the object should be converted.IRubyObject.toJava(java.lang.Class)
Copyright © 2001-2014 JRuby. All Rights Reserved.