public class RubyBigDecimal extends RubyNumeric
| Modifier and Type | Class and Description |
|---|---|
static class |
RubyBigDecimal.BigDecimalKernelMethods |
RubyNumeric.InvalidIntegerException, RubyNumeric.NumberTooLargeExceptionRubyObject.DataRubyBasicObject.Finalizer| Modifier and Type | Field and Description |
|---|---|
private static ObjectAllocator |
ALLOCATOR |
static int |
BASE |
static int |
EXCEPTION_ALL |
static int |
EXCEPTION_INFINITY |
static int |
EXCEPTION_NaN |
static int |
EXCEPTION_OVERFLOW |
static int |
EXCEPTION_UNDERFLOW |
static int |
EXCEPTION_ZERODIVIDE |
private int |
infinitySign |
private boolean |
isNaN |
private static java.util.regex.Pattern |
NUMBER_PATTERN |
static int |
ROUND_CEILING |
static int |
ROUND_DOWN |
static int |
ROUND_FLOOR |
static int |
ROUND_HALF_DOWN |
static int |
ROUND_HALF_EVEN |
static int |
ROUND_HALF_UP |
static int |
ROUND_MODE |
static int |
ROUND_UP |
static int |
SIGN_NaN |
static int |
SIGN_NEGATIVE_FINITE |
static int |
SIGN_NEGATIVE_INFINITE |
static int |
SIGN_NEGATIVE_ZERO |
static int |
SIGN_POSITIVE_FINITE |
static int |
SIGN_POSITIVE_INFINITE |
static int |
SIGN_POSITIVE_ZERO |
private static double |
SQRT_10 |
private static java.math.BigDecimal |
TWO |
private java.math.BigDecimal |
value |
private int |
zeroSign |
DBL_EPSILON, NUMERIC_ALLOCATORFIELD_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_ALLOCATORALL_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, varTableStampNULL_ARRAY| Constructor and Description |
|---|
RubyBigDecimal(Ruby runtime,
java.math.BigDecimal value) |
RubyBigDecimal(Ruby runtime,
java.math.BigDecimal value,
boolean isNan) |
RubyBigDecimal(Ruby runtime,
java.math.BigDecimal value,
int infinitySign) |
RubyBigDecimal(Ruby runtime,
java.math.BigDecimal value,
int infinitySign,
int zeroSign) |
RubyBigDecimal(Ruby runtime,
RubyBigDecimal rbd) |
RubyBigDecimal(Ruby runtime,
RubyClass klass) |
RubyBigDecimal(Ruby runtime,
RubyClass klass,
java.math.BigDecimal value) |
RubyBigDecimal(Ruby runtime,
RubyClass klass,
RubyBigDecimal rbd) |
abs, abs2, arg, asNumeric, callCoerced, callCoerced, ceil, checkInt, coerceBin, coerceBody, coerceCmp, coerceRelOp, conjugate, createNumericClass, dbl_cmp, dbl2num, denominator, div, div19, doCoerce, fdiv, fix2int, fix2int, fix2long, floatStep, floor, getCoerced, image, initialize_copy, int2fix, integer_p, magnitude, modulo, modulo19, newNumeric, nonzero_p, num_imaginary, num2chr, num2dbl, num2fix, num2int, num2long, numerator, op_cmp, op_num_equal, op_uminus, polar, quo_19, quo, real, rect, round, sadded, scalar_p, step, step, str2fnum, str2fnum, str2fnum19, str2inum, str2inum, to_c, to_int, toJava, truncate, zero_pattachToObjectSpace, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, convertToType, createObjectClass, eqlInternal, equalInternal, equals, getNativeTypeIndex, hashCode, initialize, initialize, inspect, op_eqq, puts, specificEval, toStringaddFinalizer, 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, 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_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, yieldUnderprivate static final ObjectAllocator ALLOCATOR
public static final int ROUND_DOWN
public static final int ROUND_CEILING
public static final int ROUND_UP
public static final int ROUND_HALF_DOWN
public static final int ROUND_HALF_EVEN
public static final int ROUND_HALF_UP
public static final int ROUND_FLOOR
public static final int SIGN_POSITIVE_INFINITE
public static final int EXCEPTION_OVERFLOW
public static final int SIGN_POSITIVE_ZERO
public static final int EXCEPTION_ALL
public static final int SIGN_NEGATIVE_FINITE
public static final int EXCEPTION_UNDERFLOW
public static final int SIGN_NaN
public static final int BASE
public static final int ROUND_MODE
public static final int SIGN_POSITIVE_FINITE
public static final int EXCEPTION_INFINITY
public static final int SIGN_NEGATIVE_INFINITE
public static final int EXCEPTION_ZERODIVIDE
public static final int SIGN_NEGATIVE_ZERO
public static final int EXCEPTION_NaN
private static final java.math.BigDecimal TWO
private static final double SQRT_10
private final boolean isNaN
private final int infinitySign
private final int zeroSign
private java.math.BigDecimal value
private static final java.util.regex.Pattern NUMBER_PATTERN
public RubyBigDecimal(Ruby runtime, java.math.BigDecimal value)
public RubyBigDecimal(Ruby runtime, java.math.BigDecimal value, int infinitySign)
public RubyBigDecimal(Ruby runtime, java.math.BigDecimal value, int infinitySign, int zeroSign)
public RubyBigDecimal(Ruby runtime, java.math.BigDecimal value, boolean isNan)
public RubyBigDecimal(Ruby runtime, RubyBigDecimal rbd)
public RubyBigDecimal(Ruby runtime, RubyClass klass, RubyBigDecimal rbd)
public java.math.BigDecimal getValue()
public static RubyBigDecimal newBigDecimal(IRubyObject recv, IRubyObject[] args, Block unusedBlock)
public static IRubyObject ver(IRubyObject recv)
public IRubyObject dump(IRubyObject[] args, Block unusedBlock)
public static RubyBigDecimal load(IRubyObject recv, IRubyObject from, Block block)
public static IRubyObject double_fig(IRubyObject recv)
public static IRubyObject limit(IRubyObject self, IRubyObject[] args)
public static IRubyObject save_limit(ThreadContext context, IRubyObject self, Block block)
public static IRubyObject save_exception_mode(ThreadContext context, IRubyObject self, Block block)
public static IRubyObject save_rounding_mode(ThreadContext context, IRubyObject self, Block block)
private static IRubyObject saveVariable(ThreadContext context, RubyModule BigDecimal, Block block, java.lang.String intVariableName)
public static IRubyObject mode(ThreadContext context, IRubyObject recv, IRubyObject[] args)
private static java.math.RoundingMode getRoundingMode(Ruby runtime)
private static boolean isNaNExceptionMode(Ruby runtime)
private static boolean isInfinityExceptionMode(Ruby runtime)
private static boolean isOverflowExceptionMode(Ruby runtime)
private static RubyBigDecimal cannotBeCoerced(ThreadContext context, IRubyObject value, boolean must)
private static java.lang.String errMessageType(ThreadContext context, IRubyObject value)
private static RubyBigDecimal getVpValue19(ThreadContext context, IRubyObject v, boolean must)
private static IRubyObject getVpRubyObjectWithPrec19Inner(ThreadContext context, RubyRational value, long precision, boolean must)
private static RubyBigDecimal getVpValueWithPrec19(ThreadContext context, IRubyObject value, long precision, boolean must)
private static RubyBigDecimal getVpValue(ThreadContext context, IRubyObject value, boolean must)
public static IRubyObject induced_from(ThreadContext context, IRubyObject recv, IRubyObject arg)
private static RubyBigDecimal newInstance(Ruby runtime, IRubyObject recv, RubyBigDecimal arg)
private static RubyBigDecimal newInstance(Ruby runtime, IRubyObject recv, RubyFixnum arg, java.math.MathContext mathContext)
private static RubyBigDecimal newInstance(ThreadContext context, RubyRational arg, java.math.MathContext mathContext)
private static RubyBigDecimal newInstance(Ruby runtime, IRubyObject recv, RubyFloat arg, java.math.MathContext mathContext)
private static RubyBigDecimal newInstance(Ruby runtime, IRubyObject recv, RubyBignum arg, java.math.MathContext mathContext)
private static RubyBigDecimal newInstance(ThreadContext context, IRubyObject recv, IRubyObject arg, java.math.MathContext mathContext)
@Deprecated public static RubyBigDecimal newInstance(IRubyObject recv, IRubyObject[] args)
public static RubyBigDecimal newInstance(ThreadContext context, IRubyObject recv, IRubyObject arg)
public static RubyBigDecimal newInstance(ThreadContext context, IRubyObject recv, IRubyObject arg, IRubyObject mathArg)
private static RubyBigDecimal newZero(Ruby runtime, int sign)
private static RubyBigDecimal newNaN(Ruby runtime)
private static RubyBigDecimal newInfinity(Ruby runtime, int sign)
private RubyBigDecimal setResult()
private RubyBigDecimal setResult(int scale)
public RubyFixnum hash()
RubyBasicObjecthash in class RubyBasicObjectpublic IRubyObject op_mod(ThreadContext context, IRubyObject arg)
public IRubyObject op_mod19(ThreadContext context, IRubyObject other)
public IRubyObject remainder(ThreadContext context, IRubyObject arg)
RubyNumericremainder in class RubyNumericpublic IRubyObject remainder19(ThreadContext context, IRubyObject arg)
private IRubyObject remainderInternal(ThreadContext context, RubyBigDecimal val, IRubyObject arg)
public IRubyObject op_mul(ThreadContext context, IRubyObject arg)
public IRubyObject op_mul19(ThreadContext context, IRubyObject arg)
private static IRubyObject vpPrecLimit(Ruby runtime)
public IRubyObject mult(ThreadContext context, IRubyObject b, IRubyObject n)
public IRubyObject mult19(ThreadContext context, IRubyObject b, IRubyObject n)
private RubyBigDecimal multInternal(Ruby runtime, RubyBigDecimal val, IRubyObject n)
public IRubyObject op_pow(IRubyObject arg)
public RubyBigDecimal op_pow(ThreadContext context, IRubyObject arg)
public IRubyObject op_pow19(IRubyObject exp)
public RubyBigDecimal op_pow19(ThreadContext context, IRubyObject exp)
private java.math.BigDecimal powNegative(int times)
public IRubyObject op_plus(ThreadContext context, IRubyObject b)
public IRubyObject op_plus19(ThreadContext context, IRubyObject b)
public IRubyObject add2(ThreadContext context, IRubyObject b, IRubyObject digits)
public IRubyObject add219(ThreadContext context, IRubyObject b, IRubyObject digits)
private IRubyObject addInternal(ThreadContext context, RubyBigDecimal val, IRubyObject b, IRubyObject digits)
private static int getPositiveInt(ThreadContext context, IRubyObject arg)
private RubyBigDecimal handleAddSpecialValues(ThreadContext context, RubyBigDecimal val)
public IRubyObject op_uplus()
RubyNumericop_uplus in class RubyNumericpublic IRubyObject op_minus(ThreadContext context, IRubyObject b)
public IRubyObject op_minus19(ThreadContext context, IRubyObject b)
public IRubyObject sub2(ThreadContext context, IRubyObject b, IRubyObject n)
public IRubyObject sub219(ThreadContext context, IRubyObject b, IRubyObject n)
private IRubyObject subInternal(ThreadContext context, RubyBigDecimal val, IRubyObject b)
private RubyBigDecimal handleMinusSpecialValues(ThreadContext context, RubyBigDecimal val)
public IRubyObject op_uminus()
public IRubyObject op_quo(ThreadContext context, IRubyObject other)
public IRubyObject op_quo19(ThreadContext context, IRubyObject other)
public IRubyObject op_quo20(ThreadContext context, IRubyObject other)
private IRubyObject op_quo19_20(ThreadContext context, IRubyObject other)
public IRubyObject op_div(ThreadContext context, IRubyObject other)
public IRubyObject op_div19(ThreadContext context, IRubyObject r)
public IRubyObject op_div(ThreadContext context, IRubyObject other, IRubyObject digits)
public IRubyObject op_div19(ThreadContext context, IRubyObject other, IRubyObject digits)
private IRubyObject cmp(ThreadContext context, IRubyObject arg, char op)
public IRubyObject op_cmp(ThreadContext context, IRubyObject arg)
op_cmp in class RubyBasicObjectpublic IRubyObject eql_p(ThreadContext context, IRubyObject arg)
RubyNumericeql_p in class RubyNumericpublic IRubyObject op_lt(ThreadContext context, IRubyObject arg)
public IRubyObject op_le(ThreadContext context, IRubyObject arg)
public IRubyObject op_gt(ThreadContext context, IRubyObject arg)
public IRubyObject op_ge(ThreadContext context, IRubyObject arg)
public IRubyObject abs()
public IRubyObject ceil(IRubyObject[] args)
public IRubyObject ceil19(IRubyObject[] args)
public IRubyObject coerce(IRubyObject other)
RubyNumericcoerce in class RubyNumericpublic RubyArray coerce(ThreadContext context, IRubyObject other)
public double getDoubleValue()
getDoubleValue in class RubyNumericpublic long getLongValue()
getLongValue in class RubyNumericpublic java.math.BigInteger getBigIntegerValue()
getBigIntegerValue in class RubyNumericpublic java.math.BigDecimal getBigDecimalValue()
public RubyNumeric multiplyWith(ThreadContext context, RubyInteger value)
public RubyNumeric multiplyWith(ThreadContext context, RubyFloat value)
public RubyNumeric multiplyWith(ThreadContext context, RubyBignum value)
public IRubyObject divmod(ThreadContext context, IRubyObject other)
RubyNumericdivmod in class RubyNumericpublic IRubyObject divmod19(ThreadContext context, IRubyObject other)
RubyNumericdivmod19 in class RubyNumericpublic IRubyObject exponent()
public IRubyObject finite_p()
public IRubyObject floor(IRubyObject[] args)
public IRubyObject floor19(IRubyObject[] args)
public IRubyObject frac()
public IRubyObject infinite_p()
public IRubyObject inspect(ThreadContext context)
public IRubyObject nan_p()
public IRubyObject nonzero_p()
public IRubyObject precs()
@Deprecated public IRubyObject round(IRubyObject[] args)
public IRubyObject round(ThreadContext context, IRubyObject[] args)
private static java.math.RoundingMode javaRoundingModeFromRubyRoundingMode(Ruby runtime, IRubyObject arg)
public IRubyObject sign()
public RubyArray split()
private java.lang.String getSignificantDigits()
private java.lang.String getAllDigits()
private int getExponent()
public IRubyObject sqrt(IRubyObject arg)
public IRubyObject to_f()
public IRubyObject to_int()
public IRubyObject to_int19()
private java.lang.String removeTrailingZeroes(java.lang.String in)
public static boolean formatHasLeadingPlus(java.lang.String format)
public static boolean formatHasLeadingSpace(java.lang.String format)
public static boolean formatHasFloatingPointNotation(java.lang.String format)
public static int formatFractionalDigitGroups(java.lang.String format)
private static java.lang.String firstArgument(IRubyObject[] args)
private static boolean posSpace(java.lang.String arg)
private static boolean posSign(java.lang.String arg)
private static boolean asEngineering(java.lang.String arg)
private static int groups(java.lang.String arg)
private boolean isZero()
private boolean isOne()
private boolean isNaN()
private boolean isInfinity()
private java.lang.String unscaledValue()
private java.lang.String sign(java.lang.String arg,
int signum)
private java.lang.CharSequence engineeringValue(java.lang.String arg)
private java.lang.CharSequence floatingPointValue(java.lang.String arg)
public RubyString to_s(IRubyObject[] args)
public IRubyObject fix()
public IRubyObject truncate(IRubyObject[] args)
public IRubyObject truncate19(IRubyObject[] args)
public IRubyObject zero_p()
public static java.math.BigDecimal bigSqrt(java.math.BigDecimal squarD,
java.math.MathContext rootMC)
The code is based on Frans Lelieveld's code , used here with permission.
squarD - The number to get the root from.rootMC - Precision and rounding mode.java.lang.ArithmeticException - if the argument number is negativejava.lang.IllegalArgumentException - if rootMC has precision 0http://oldblog.novaloka.nl/blogger.xs4all.nl/novaloka/archive/2007/09/15/295396.htmlprivate void checkFloatDomain()
private boolean is_even(IRubyObject x)