|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jruby.RubyObject
org.jruby.RubyNumeric
public class RubyNumeric
Base class for all numerical types in ruby.
Nested Class Summary | |
---|---|
static class |
RubyNumeric.InvalidIntegerException
|
static class |
RubyNumeric.NumberTooLargeException
|
Nested classes/interfaces inherited from class org.jruby.RubyObject |
---|
RubyObject.Finalizer |
Field Summary | |
---|---|
static double |
DBL_EPSILON
|
protected static ObjectAllocator |
NUMERIC_ALLOCATOR
|
Fields inherited from class org.jruby.RubyObject |
---|
instanceVariables, isTrue, metaClass, NEVER, OBJECT_ALLOCATOR |
Fields inherited from interface org.jruby.runtime.builtin.IRubyObject |
---|
NULL_ARRAY |
Constructor Summary | |
---|---|
RubyNumeric(Ruby runtime,
RubyClass metaClass)
|
Method Summary | |
---|---|
IRubyObject |
abs()
num_abs |
RubyNumeric |
asNumeric()
|
protected IRubyObject |
callCoerced(java.lang.String method,
IRubyObject other)
|
protected IRubyObject |
callCoerced(java.lang.String method,
IRubyObject other,
boolean err)
|
IRubyObject |
ceil()
num_ceil |
static void |
checkInt(IRubyObject arg,
long num)
check_int |
IRubyObject |
cmp(IRubyObject other)
num_cmp |
IRubyObject |
coerce(IRubyObject other)
num_coerce |
protected IRubyObject |
coerceBin(java.lang.String method,
IRubyObject other)
rb_num_coerce_bin coercion taking two arguments |
protected IRubyObject |
coerceBody(IRubyObject other)
coerce_body |
protected IRubyObject |
coerceCmp(java.lang.String method,
IRubyObject other)
rb_num_coerce_cmp coercion used for comparisons |
protected IRubyObject |
coerceRelOp(java.lang.String method,
IRubyObject other)
rb_num_coerce_relop coercion used for relative operators |
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 |
div(IRubyObject other)
num_div |
IRubyObject |
divmod(IRubyObject other)
num_divmod |
protected RubyArray |
doCoerce(IRubyObject other,
boolean err)
do_coerce |
IRubyObject |
eql_p(IRubyObject other)
num_eql |
IRubyObject |
equal(IRubyObject other)
num_equal |
static int |
fix2int(IRubyObject arg)
|
static long |
fix2long(IRubyObject arg)
|
IRubyObject |
floor()
num_floor |
protected IRubyObject[] |
getCoerced(IRubyObject other,
boolean error)
Numeric methods. |
double |
getDoubleValue()
|
long |
getLongValue()
|
IRubyObject |
init_copy(IRubyObject arg)
num_init_copy |
IRubyObject |
int_p()
num_int_p |
static RubyNumeric |
int2fix(Ruby runtime,
long val)
|
IRubyObject |
modulo(IRubyObject other)
num_modulo |
static RubyNumeric |
newNumeric(Ruby runtime)
|
IRubyObject |
nonzero_p()
num_nonzero_p |
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 |
quo(IRubyObject other)
num_quo |
IRubyObject |
remainder(IRubyObject y)
num_remainder |
IRubyObject |
round()
num_round |
IRubyObject |
sadded(IRubyObject name)
num_sadded |
IRubyObject |
step(IRubyObject[] args,
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 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_int()
num_to_int |
IRubyObject |
truncate()
num_truncate |
IRubyObject |
uminus()
num_uminus |
IRubyObject |
uplus()
num_uplus |
IRubyObject |
zero_p()
num_zero_p |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static ObjectAllocator NUMERIC_ALLOCATOR
public static double DBL_EPSILON
Constructor Detail |
---|
public RubyNumeric(Ruby runtime, RubyClass metaClass)
Method Detail |
---|
public static RubyClass createNumericClass(Ruby runtime)
public double getDoubleValue()
public long getLongValue()
public static RubyNumeric newNumeric(Ruby runtime)
public static int num2int(IRubyObject arg)
public static void checkInt(IRubyObject arg, long num)
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 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/criteria
public 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/criteria
protected IRubyObject[] getCoerced(IRubyObject other, boolean error)
protected IRubyObject callCoerced(java.lang.String method, IRubyObject other, boolean err)
protected IRubyObject callCoerced(java.lang.String method, IRubyObject other)
protected final IRubyObject coerceBody(IRubyObject other)
protected final RubyArray doCoerce(IRubyObject other, boolean err)
protected final IRubyObject coerceBin(java.lang.String method, IRubyObject other)
protected final IRubyObject coerceCmp(java.lang.String method, IRubyObject other)
protected final IRubyObject coerceRelOp(java.lang.String method, IRubyObject other)
public RubyNumeric asNumeric()
public IRubyObject sadded(IRubyObject name)
public IRubyObject init_copy(IRubyObject arg)
public IRubyObject coerce(IRubyObject other)
public IRubyObject uplus()
public IRubyObject uminus()
public IRubyObject cmp(IRubyObject other)
public IRubyObject eql_p(IRubyObject other)
public IRubyObject quo(IRubyObject other)
public IRubyObject div(IRubyObject other)
public IRubyObject divmod(IRubyObject other)
public IRubyObject modulo(IRubyObject other)
public IRubyObject remainder(IRubyObject y)
public IRubyObject abs()
public IRubyObject to_int()
public IRubyObject int_p()
public IRubyObject zero_p()
public IRubyObject nonzero_p()
public IRubyObject floor()
public IRubyObject ceil()
public IRubyObject round()
public IRubyObject truncate()
public IRubyObject step(IRubyObject[] args, Block block)
public IRubyObject equal(IRubyObject other)
equal
in interface IRubyObject
equal
in class RubyObject
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |