org.jruby
Class RubyBigDecimal
java.lang.Object
org.jruby.RubyObject
org.jruby.RubyNumeric
org.jruby.RubyBigDecimal
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, InstanceVariables, InternalVariables, IRubyObject, CoreObjectType
public class RubyBigDecimal
- extends RubyNumeric
- Author:
- Ola Bini
- See Also:
- Serialized Form
Fields inherited from class org.jruby.RubyObject |
ALL_F, ERR_INSECURE_SET_INST_VAR, FALSE_F, FL_USHIFT, flags, FROZEN_F, metaClass, NEVER, NIL_F, OBJECT_ALLOCATOR, TAINTED_F, UNDEF, USER0_F, USER1_F, USER2_F, USER3_F, USER4_F, USER5_F, USER6_F, USER7_F, VARIABLE_TABLE_DEFAULT_CAPACITY, VARIABLE_TABLE_EMPTY_TABLE, VARIABLE_TABLE_LOAD_FACTOR, VARIABLE_TABLE_MAXIMUM_CAPACITY, variableTable, variableTableSize, variableTableThreshold |
Method Summary |
IRubyObject |
abs()
|
IRubyObject |
add2(ThreadContext context,
IRubyObject b,
IRubyObject digits)
|
static java.math.BigDecimal |
bigSqrt(java.math.BigDecimal squarD,
java.math.MathContext rootMC)
Returns the correctly rounded square root of a positive
BigDecimal. |
IRubyObject |
ceil(IRubyObject[] args)
|
IRubyObject |
coerce(IRubyObject other)
num_coerce |
static RubyClass |
createBigDecimal(Ruby runtime)
|
IRubyObject |
divmod(ThreadContext context,
IRubyObject other)
num_divmod |
static IRubyObject |
double_fig(IRubyObject recv)
|
IRubyObject |
dump(IRubyObject[] args,
Block unusedBlock)
|
IRubyObject |
eql_p(ThreadContext context,
IRubyObject arg)
num_eql |
IRubyObject |
exponent()
|
IRubyObject |
finite_p()
|
IRubyObject |
fix()
|
IRubyObject |
floor(IRubyObject[] args)
|
static int |
formatFractionalDigitGroups(java.lang.String format)
|
static boolean |
formatHasFloatingPointNotation(java.lang.String format)
|
static boolean |
formatHasLeadingPlus(java.lang.String format)
|
static boolean |
formatHasLeadingSpace(java.lang.String format)
|
IRubyObject |
frac()
|
double |
getDoubleValue()
|
long |
getLongValue()
|
java.math.BigDecimal |
getValue()
|
RubyFixnum |
hash()
rb_obj_id
Will return the hash code of this object. |
IRubyObject |
infinite_p()
|
IRubyObject |
inspect(ThreadContext context)
|
static IRubyObject |
limit(IRubyObject recv,
IRubyObject[] args)
|
static RubyBigDecimal |
load(IRubyObject recv,
IRubyObject from,
Block block)
|
static IRubyObject |
mode(ThreadContext context,
IRubyObject recv,
IRubyObject[] args)
|
IRubyObject |
mult2(ThreadContext context,
IRubyObject b,
IRubyObject n)
|
RubyNumeric |
multiplyWith(ThreadContext context,
RubyBignum value)
|
RubyNumeric |
multiplyWith(ThreadContext context,
RubyFloat value)
|
RubyNumeric |
multiplyWith(ThreadContext context,
RubyInteger value)
|
IRubyObject |
nan_p()
|
static RubyBigDecimal |
newBigDecimal(IRubyObject recv,
IRubyObject[] args,
Block unusedBlock)
|
static RubyBigDecimal |
newInstance(IRubyObject recv,
IRubyObject[] args)
|
IRubyObject |
nonzero_p()
|
IRubyObject |
op_cmp(ThreadContext context,
IRubyObject arg)
|
IRubyObject |
op_div(ThreadContext context,
IRubyObject other)
|
IRubyObject |
op_div(ThreadContext context,
IRubyObject other,
IRubyObject digits)
|
IRubyObject |
op_ge(ThreadContext context,
IRubyObject arg)
|
IRubyObject |
op_gt(ThreadContext context,
IRubyObject arg)
|
IRubyObject |
op_le(ThreadContext context,
IRubyObject arg)
|
IRubyObject |
op_lt(ThreadContext context,
IRubyObject arg)
|
IRubyObject |
op_minus(ThreadContext context,
IRubyObject arg)
|
IRubyObject |
op_mod(ThreadContext context,
IRubyObject arg)
|
IRubyObject |
op_mul(ThreadContext context,
IRubyObject arg)
|
IRubyObject |
op_plus(ThreadContext context,
IRubyObject b)
|
IRubyObject |
op_pow(IRubyObject arg)
|
IRubyObject |
op_quo(ThreadContext context,
IRubyObject other)
|
IRubyObject |
op_uminus()
|
IRubyObject |
op_uplus()
num_uplus |
IRubyObject |
precs()
|
IRubyObject |
remainder(ThreadContext context,
IRubyObject arg)
num_remainder |
IRubyObject |
round(IRubyObject[] args)
|
IRubyObject |
sign()
|
RubyArray |
split()
|
IRubyObject |
sqrt(IRubyObject arg)
|
IRubyObject |
sub2(ThreadContext context,
IRubyObject b,
IRubyObject n)
|
IRubyObject |
to_f()
|
IRubyObject |
to_int()
|
IRubyObject |
to_s(IRubyObject[] args)
|
IRubyObject |
truncate()
num_truncate |
IRubyObject |
truncate(IRubyObject arg)
|
static IRubyObject |
ver(IRubyObject recv)
|
IRubyObject |
zero_p()
|
Methods inherited from class org.jruby.RubyNumeric |
abs, asNumeric, callCoerced, callCoerced, ceil, checkInt, coerceBin, coerceBody, coerceCmp, coerceRelOp, createNumericClass, dbl_cmp, dbl2num, div, doCoerce, fix2int, fix2long, floor, getCoerced, initialize_copy, int2fix, integer_p, modulo, newNumeric, nonzero_p, num2chr, num2dbl, num2fix, num2int, num2long, op_cmp, op_num_equal, op_uminus, quo, round, sadded, step, step, step, str2fnum, str2fnum, str2inum, str2inum, to_int, zero_p |
Methods inherited from class org.jruby.RubyObject |
addFinalizer, anyToString, as, asJavaString, asString, attachToObjectSpace, callInit, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callSuper, checkArrayType, checkFrozen, checkStringType, convertToArray, convertToFloat, convertToHash, convertToInteger, convertToInteger, convertToString, convertToType, copySpecialInstanceVariables, createObjectClass, dataGetStruct, dataWrapStruct, display, dup, ensureInstanceVariablesSettable, eql_p, eql, eqlInternal, equal_p, equalInternal, equals, evalUnder, evalUnder, extend, fastGetInstanceVariable, fastGetInternalVariable, fastHasInstanceVariable, fastHasInternalVariable, fastSetInstanceVariable, fastSetInternalVariable, freeze, frozen_p, getFlag, getInstanceVariable, getInstanceVariableList, getInstanceVariableNameList, getInstanceVariables, getInternalVariable, getInternalVariableList, getInternalVariables, getJavaClass, getMetaClass, getNativeTypeIndex, getRuntime, getSingletonClass, getSingletonClassClone, getType, getVariableCount, getVariableList, getVariableMap, getVariableNameList, hashCode, hasInstanceVariable, hasInternalVariable, hasVariables, id_deprecated, id, infectBy, initialize, inspect, 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, isClass, isFalse, isFrozen, isImmediate, isModule, isNil, isRubyVariable, isTaint, isTrue, kind_of_p, makeMetaClass, method, methods, nil_p, op_eqq, op_equal, op_match, private_methods, protected_methods, public_methods, puts, rbClone, remove_instance_variable, removeFinalizers, removeInstanceVariable, removeInternalVariable, respond_to_p, respond_to_p, respondsTo, send, setFlag, setFrozen, setInstanceVariable, setInternalVariable, setMetaClass, setTaint, singleton_methods, specificEval, specificEval, specificEval, specificEval, specificEval, syncVariables, taint, tainted_p, testFrozen, to_a, to_java, to_s, toString, type_deprecated, type, untaint, validateInstanceVariable, variableTableContains, variableTableFastContains, variableTableFastFetch, variableTableFastStore, variableTableFetch, variableTableGetMap, variableTableGetMap, variableTableGetSize, variableTableGetTable, variableTableReadLocked, variableTableRehash, variableTableRemove, variableTableStore, variableTableSync |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
ROUND_DOWN
public static final int ROUND_DOWN
- See Also:
- Constant Field Values
ROUND_CEILING
public static final int ROUND_CEILING
- See Also:
- Constant Field Values
ROUND_UP
public static final int ROUND_UP
- See Also:
- Constant Field Values
ROUND_HALF_DOWN
public static final int ROUND_HALF_DOWN
- See Also:
- Constant Field Values
ROUND_HALF_EVEN
public static final int ROUND_HALF_EVEN
- See Also:
- Constant Field Values
ROUND_HALF_UP
public static final int ROUND_HALF_UP
- See Also:
- Constant Field Values
ROUND_FLOOR
public static final int ROUND_FLOOR
- See Also:
- Constant Field Values
SIGN_POSITIVE_INFINITE
public static final int SIGN_POSITIVE_INFINITE
- See Also:
- Constant Field Values
EXCEPTION_OVERFLOW
public static final int EXCEPTION_OVERFLOW
- See Also:
- Constant Field Values
SIGN_POSITIVE_ZERO
public static final int SIGN_POSITIVE_ZERO
- See Also:
- Constant Field Values
EXCEPTION_ALL
public static final int EXCEPTION_ALL
- See Also:
- Constant Field Values
SIGN_NEGATIVE_FINITE
public static final int SIGN_NEGATIVE_FINITE
- See Also:
- Constant Field Values
EXCEPTION_UNDERFLOW
public static final int EXCEPTION_UNDERFLOW
- See Also:
- Constant Field Values
SIGN_NaN
public static final int SIGN_NaN
- See Also:
- Constant Field Values
BASE
public static final int BASE
- See Also:
- Constant Field Values
ROUND_MODE
public static final int ROUND_MODE
- See Also:
- Constant Field Values
SIGN_POSITIVE_FINITE
public static final int SIGN_POSITIVE_FINITE
- See Also:
- Constant Field Values
EXCEPTION_INFINITY
public static final int EXCEPTION_INFINITY
- See Also:
- Constant Field Values
SIGN_NEGATIVE_INFINITE
public static final int SIGN_NEGATIVE_INFINITE
- See Also:
- Constant Field Values
EXCEPTION_ZERODIVIDE
public static final int EXCEPTION_ZERODIVIDE
- See Also:
- Constant Field Values
SIGN_NEGATIVE_ZERO
public static final int SIGN_NEGATIVE_ZERO
- See Also:
- Constant Field Values
EXCEPTION_NaN
public static final int EXCEPTION_NaN
- See Also:
- Constant Field Values
RubyBigDecimal
public RubyBigDecimal(Ruby runtime,
RubyClass klass)
RubyBigDecimal
public RubyBigDecimal(Ruby runtime,
java.math.BigDecimal value)
createBigDecimal
public static RubyClass createBigDecimal(Ruby runtime)
getValue
public java.math.BigDecimal getValue()
newBigDecimal
public static RubyBigDecimal newBigDecimal(IRubyObject recv,
IRubyObject[] args,
Block unusedBlock)
ver
public static IRubyObject ver(IRubyObject recv)
dump
public IRubyObject dump(IRubyObject[] args,
Block unusedBlock)
load
public static RubyBigDecimal load(IRubyObject recv,
IRubyObject from,
Block block)
double_fig
public static IRubyObject double_fig(IRubyObject recv)
limit
public static IRubyObject limit(IRubyObject recv,
IRubyObject[] args)
mode
public static IRubyObject mode(ThreadContext context,
IRubyObject recv,
IRubyObject[] args)
newInstance
public static RubyBigDecimal newInstance(IRubyObject recv,
IRubyObject[] args)
hash
public RubyFixnum hash()
- Description copied from class:
RubyObject
- rb_obj_id
Will 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:
hash
in class RubyObject
op_mod
public IRubyObject op_mod(ThreadContext context,
IRubyObject arg)
remainder
public IRubyObject remainder(ThreadContext context,
IRubyObject arg)
- Description copied from class:
RubyNumeric
- num_remainder
- Overrides:
remainder
in class RubyNumeric
op_mul
public IRubyObject op_mul(ThreadContext context,
IRubyObject arg)
mult2
public IRubyObject mult2(ThreadContext context,
IRubyObject b,
IRubyObject n)
op_pow
public IRubyObject op_pow(IRubyObject arg)
op_plus
public IRubyObject op_plus(ThreadContext context,
IRubyObject b)
add2
public IRubyObject add2(ThreadContext context,
IRubyObject b,
IRubyObject digits)
op_uplus
public IRubyObject op_uplus()
- Description copied from class:
RubyNumeric
- num_uplus
- Overrides:
op_uplus
in class RubyNumeric
op_minus
public IRubyObject op_minus(ThreadContext context,
IRubyObject arg)
sub2
public IRubyObject sub2(ThreadContext context,
IRubyObject b,
IRubyObject n)
op_uminus
public IRubyObject op_uminus()
op_quo
public IRubyObject op_quo(ThreadContext context,
IRubyObject other)
op_div
public IRubyObject op_div(ThreadContext context,
IRubyObject other)
op_div
public IRubyObject op_div(ThreadContext context,
IRubyObject other,
IRubyObject digits)
op_cmp
public IRubyObject op_cmp(ThreadContext context,
IRubyObject arg)
eql_p
public IRubyObject eql_p(ThreadContext context,
IRubyObject arg)
- Description copied from class:
RubyNumeric
- num_eql
- Overrides:
eql_p
in class RubyNumeric
op_lt
public IRubyObject op_lt(ThreadContext context,
IRubyObject arg)
op_le
public IRubyObject op_le(ThreadContext context,
IRubyObject arg)
op_gt
public IRubyObject op_gt(ThreadContext context,
IRubyObject arg)
op_ge
public IRubyObject op_ge(ThreadContext context,
IRubyObject arg)
abs
public IRubyObject abs()
ceil
public IRubyObject ceil(IRubyObject[] args)
coerce
public IRubyObject coerce(IRubyObject other)
- Description copied from class:
RubyNumeric
- num_coerce
- Overrides:
coerce
in class RubyNumeric
getDoubleValue
public double getDoubleValue()
- Overrides:
getDoubleValue
in class RubyNumeric
getLongValue
public long getLongValue()
- Overrides:
getLongValue
in class RubyNumeric
multiplyWith
public RubyNumeric multiplyWith(ThreadContext context,
RubyInteger value)
multiplyWith
public RubyNumeric multiplyWith(ThreadContext context,
RubyFloat value)
multiplyWith
public RubyNumeric multiplyWith(ThreadContext context,
RubyBignum value)
divmod
public IRubyObject divmod(ThreadContext context,
IRubyObject other)
- Description copied from class:
RubyNumeric
- num_divmod
- Overrides:
divmod
in class RubyNumeric
exponent
public IRubyObject exponent()
finite_p
public IRubyObject finite_p()
floor
public IRubyObject floor(IRubyObject[] args)
frac
public IRubyObject frac()
infinite_p
public IRubyObject infinite_p()
inspect
public IRubyObject inspect(ThreadContext context)
nan_p
public IRubyObject nan_p()
nonzero_p
public IRubyObject nonzero_p()
precs
public IRubyObject precs()
round
public IRubyObject round(IRubyObject[] args)
sign
public IRubyObject sign()
split
public RubyArray split()
sqrt
public IRubyObject sqrt(IRubyObject arg)
to_f
public IRubyObject to_f()
to_int
public IRubyObject to_int()
formatHasLeadingPlus
public static boolean formatHasLeadingPlus(java.lang.String format)
formatHasLeadingSpace
public static boolean formatHasLeadingSpace(java.lang.String format)
formatHasFloatingPointNotation
public static boolean formatHasFloatingPointNotation(java.lang.String format)
formatFractionalDigitGroups
public static int formatFractionalDigitGroups(java.lang.String format)
to_s
public IRubyObject to_s(IRubyObject[] args)
fix
public IRubyObject fix()
truncate
public IRubyObject truncate()
- Description copied from class:
RubyNumeric
- num_truncate
- Overrides:
truncate
in class RubyNumeric
truncate
public IRubyObject truncate(IRubyObject arg)
zero_p
public IRubyObject zero_p()
bigSqrt
public static java.math.BigDecimal bigSqrt(java.math.BigDecimal squarD,
java.math.MathContext rootMC)
- Returns the correctly rounded square root of a positive
BigDecimal. This method performs the fast Square Root by
Coupled Newton Iteration algorithm by Timm Ahrendt, from
the book "Pi, unleashed" by J??rg Arndt in a neat loop.
The code is based on Frans Lelieveld's code , used here with
permission.
- Parameters:
squarD
- The number to get the root from.rootMC
- Precision and rounding mode.
- Returns:
- the root of the argument number
- Throws:
java.lang.ArithmeticException
- if the argument number is negative
java.lang.IllegalArgumentException
- if rootMC has precision 0
Copyright © 2002-2007 JRuby Team. All Rights Reserved.