Ruby 2.0.0p247(2013-06-27revision41674)

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

Macros | Functions | Variables
bigdecimal.c File Reference
`#include "bigdecimal.h"`
`#include <assert.h>`
`#include <ctype.h>`
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include <errno.h>`
`#include <math.h>`
Include dependency graph for bigdecimal.c:

Go to the source code of this file.

## Macros
#define | NDEBUG
#define | ENTER(n) volatile VALUE RB_UNUSED_VAR(vStack[n]);int iStack=0
#define | PUSH(x) vStack[iStack++] = (VALUE)(x);
#define | SAVE(p) PUSH(p->obj);
#define | GUARD_OBJ(p, y) {p=y;SAVE(p);}
#define | BASE_FIG RMPD_COMPONENT_FIGURES
#define | BASE RMPD_BASE
#define | HALF_BASE (BASE/2)
#define | BASE1 (BASE/10)
#define | DBLE_FIG (DBL_DIG+1) /* figure of double */
#define | RBIGNUM_ZERO_P(x)
#define | RRATIONAL_ZERO_P(x)
#define | RRATIONAL_NEGATIVE_P(x) RTEST(rb_funcall((x), '<', 1, INT2FIX(0)))
#define | DoSomeOne(x, y, f) rb_num_coerce_bin(x,y,f)
#define | VpAllocReal(prec) (Real *)VpMemAlloc(offsetof(Real, frac) + (prec) * sizeof(BDIGIT))
#define | VpReallocReal(ptr, prec) (Real *)VpMemRealloc((ptr), offsetof(Real, frac) + (prec) * sizeof(BDIGIT))
#define | BigMath_exp(x, n) BigMath_s_exp(rb_mBigMath, (x), (n))
#define | BigMath_log(x, n) BigMath_s_log(rb_mBigMath, (x), (n))
#define | is_positive(x) (!is_negative(x))
#define | maxnr 100UL /* Maximum iterations for calcurating sqrt. */
#define | MemCmp(x, y, z) memcmp(x,y,z)
#define | StrCmp(x, y) strcmp(x,y)
#define | rmpd_set_thread_local_exception_mode(mode)
#define | rmpd_set_thread_local_precision_limit(limit)
#define | RMPD_PRECISION_LIMIT_DEFAULT ((size_t)0)
#define | rmpd_set_thread_local_rounding_mode(mode)

## Functions
static int | bigzero_p (VALUE x)
static VALUE | BigDecimal_version (VALUE self)
static unsigned short | VpGetException (void)
static void | VpSetException (unsigned short f)
static void | VpInternalRound (Real *c, size_t ixDigit, BDIGIT vPrev, BDIGIT v)
static int | VpLimitRound (Real *c, size_t ixDigit)
static Real * | VpCopy (Real *pv, Real const *const x)
static void | BigDecimal_delete (void *pv)
static size_t | BigDecimal_memsize (const void *ptr)
static int | is_kind_of_BigDecimal (VALUE const v)
static VALUE | ToValue (Real *p)
| NORETURN (static void cannot_be_coerced_into_BigDecimal(VALUE, VALUE))
static void | cannot_be_coerced_into_BigDecimal (VALUE exc_class, VALUE v)
static VALUE | BigDecimal_div2 (int, VALUE *, VALUE)
static Real * | GetVpValueWithPrec (VALUE v, long prec, int must)
static Real * | GetVpValue (VALUE v, int must)
static VALUE | BigDecimal_double_fig (VALUE self)
static VALUE | BigDecimal_prec (VALUE self)
static VALUE | BigDecimal_hash (VALUE self)
static VALUE | BigDecimal_dump (int argc, VALUE *argv, VALUE self)
static VALUE | BigDecimal_load (VALUE self, VALUE str)
static unsigned short | check_rounding_mode (VALUE const v)
static VALUE | BigDecimal_mode (int argc, VALUE *argv, VALUE self)
static size_t | GetAddSubPrec (Real *a, Real *b)
static SIGNED_VALUE | GetPositiveInt (VALUE v)
VP_EXPORT Real * | VpNewRbClass (size_t mx, const char *str, VALUE klass)
VP_EXPORT Real * | VpCreateRbObject (size_t mx, const char *str)
static VALUE | BigDecimal_IsNaN (VALUE self)
static VALUE | BigDecimal_IsInfinite (VALUE self)
static VALUE | BigDecimal_IsFinite (VALUE self)
static void | BigDecimal_check_num (Real *p)
static VALUE | BigDecimal_split (VALUE self)
static VALUE | BigDecimal_to_i (VALUE self)
static VALUE | BigDecimal_to_f (VALUE self)
static VALUE | BigDecimal_to_r (VALUE self)
static VALUE | BigDecimal_coerce (VALUE self, VALUE other)
static VALUE | BigDecimal_uplus (VALUE self)
static VALUE | BigDecimal_add (VALUE self, VALUE r)
static VALUE | BigDecimal_sub (VALUE self, VALUE r)
static VALUE | BigDecimalCmp (VALUE self, VALUE r, char op)
static VALUE | BigDecimal_zero (VALUE self)
static VALUE | BigDecimal_nonzero (VALUE self)
static VALUE | BigDecimal_comp (VALUE self, VALUE r)
static VALUE | BigDecimal_eq (VALUE self, VALUE r)
static VALUE | BigDecimal_lt (VALUE self, VALUE r)
static VALUE | BigDecimal_le (VALUE self, VALUE r)
static VALUE | BigDecimal_gt (VALUE self, VALUE r)
static VALUE | BigDecimal_ge (VALUE self, VALUE r)
static VALUE | BigDecimal_neg (VALUE self)
static VALUE | BigDecimal_mult (VALUE self, VALUE r)
static VALUE | BigDecimal_divide (Real **c, Real **res, Real **div, VALUE self, VALUE r)
static VALUE | BigDecimal_div (VALUE self, VALUE r)
static VALUE | BigDecimal_DoDivmod (VALUE self, VALUE r, Real **div, Real **mod)
static VALUE | BigDecimal_mod (VALUE self, VALUE r)
static VALUE | BigDecimal_divremain (VALUE self, VALUE r, Real **dv, Real **rv)
static VALUE | BigDecimal_remainder (VALUE self, VALUE r)
static VALUE | BigDecimal_divmod (VALUE self, VALUE r)
static VALUE | BigDecimal_add2 (VALUE self, VALUE b, VALUE n)
static VALUE | BigDecimal_sub2 (VALUE self, VALUE b, VALUE n)
static VALUE | BigDecimal_mult2 (VALUE self, VALUE b, VALUE n)
static VALUE | BigDecimal_abs (VALUE self)
static VALUE | BigDecimal_sqrt (VALUE self, VALUE nFig)
static VALUE | BigDecimal_fix (VALUE self)
static VALUE | BigDecimal_round (int argc, VALUE *argv, VALUE self)
static VALUE | BigDecimal_truncate (int argc, VALUE *argv, VALUE self)
static VALUE | BigDecimal_frac (VALUE self)
static VALUE | BigDecimal_floor (int argc, VALUE *argv, VALUE self)
static VALUE | BigDecimal_ceil (int argc, VALUE *argv, VALUE self)
static VALUE | BigDecimal_to_s (int argc, VALUE *argv, VALUE self)
static VALUE | BigDecimal_exponent (VALUE self)
static VALUE | BigDecimal_inspect (VALUE self)
static VALUE | BigMath_s_exp (VALUE, VALUE, VALUE)
static VALUE | BigMath_s_log (VALUE, VALUE, VALUE)
static int | is_integer (VALUE x)
static int | is_negative (VALUE x)
static int | is_zero (VALUE x)
static int | is_one (VALUE x)
static int | is_even (VALUE x)
static VALUE | rmpd_power_by_big_decimal (Real const *x, Real const *exp, ssize_t const n)
static VALUE | BigDecimal_power (int argc, VALUE *argv, VALUE self)
static VALUE | BigDecimal_power_op (VALUE self, VALUE exp)
static VALUE | BigDecimal_s_allocate (VALUE klass)
static Real * | BigDecimal_new (int argc, VALUE *argv)
static VALUE | BigDecimal_initialize (int argc, VALUE *argv, VALUE self)
static VALUE | BigDecimal_initialize_copy (VALUE self, VALUE other)
static VALUE | BigDecimal_global_new (int argc, VALUE *argv, VALUE self)
static VALUE | BigDecimal_limit (int argc, VALUE *argv, VALUE self)
static VALUE | BigDecimal_sign (VALUE self)
static VALUE | BigDecimal_save_exception_mode (VALUE self)
static VALUE | BigDecimal_save_rounding_mode (VALUE self)
static VALUE | BigDecimal_save_limit (VALUE self)
void | Init_bigdecimal (void)
static int | VpIsDefOP (Real *c, Real *a, Real *b, int sw)
static int | AddExponent (Real *a, SIGNED_VALUE n)
static BDIGIT | VpAddAbs (Real *a, Real *b, Real *c)
static BDIGIT | VpSubAbs (Real *a, Real *b, Real *c)
static size_t | VpSetPTR (Real *a, Real *b, Real *c, size_t *a_pos, size_t *b_pos, size_t *c_pos, BDIGIT *av, BDIGIT *bv)
static int | VpNmlz (Real *a)
static void | VpFormatSt (char *psz, size_t fFmt)
static int | VpRdup (Real *m, size_t ind_m)
VP_EXPORT void * | VpMemAlloc (size_t mb)
VP_EXPORT void * | VpMemRealloc (void *ptr, size_t mb)
VP_EXPORT void | VpFree (Real *pv)
VP_EXPORT size_t | VpGetPrecLimit (void)
VP_EXPORT size_t | VpSetPrecLimit (size_t n)
VP_EXPORT unsigned short | VpGetRoundMode (void)
VP_EXPORT int | VpIsRoundMode (unsigned short n)
VP_EXPORT unsigned short | VpSetRoundMode (unsigned short n)
static double | Zero (void)
static double | One (void)
VP_EXPORT double | VpGetDoubleNaN (void)
VP_EXPORT double | VpGetDoublePosInf (void)
VP_EXPORT double | VpGetDoubleNegInf (void)
VP_EXPORT double | VpGetDoubleNegZero (void)
VP_EXPORT int | VpException (unsigned short f, const char *str, int always)
VP_EXPORT size_t | VpNumOfChars (Real *vp, const char *pszFmt)
VP_EXPORT size_t | VpInit (BDIGIT BaseVal)
VP_EXPORT Real * | VpOne (void)
VP_EXPORT Real * | VpAlloc (size_t mx, const char *szVal)
VP_EXPORT size_t | VpAsgn (Real *c, Real *a, int isw)
VP_EXPORT size_t | VpAddSub (Real *c, Real *a, Real *b, int operation)
VP_EXPORT size_t | VpMult (Real *c, Real *a, Real *b)
VP_EXPORT size_t | VpDivd (Real *c, Real *r, Real *a, Real *b)
VP_EXPORT int | VpComp (Real *a, Real *b)
VP_EXPORT ssize_t | VpExponent10 (Real *a)
VP_EXPORT void | VpSzMantissa (Real *a, char *psz)
VP_EXPORT int | VpToSpecialString (Real *a, char *psz, int fPlus)
VP_EXPORT void | VpToString (Real *a, char *psz, size_t fFmt, int fPlus)
VP_EXPORT void | VpToFString (Real *a, char *psz, size_t fFmt, int fPlus)
VP_EXPORT int | VpCtoV (Real *a, const char *int_chr, size_t ni, const char *frac, size_t nf, const char *exp_chr, size_t ne)
VP_EXPORT int | VpVtoD (double *d, SIGNED_VALUE *e, Real *m)
VP_EXPORT void | VpDtoV (Real *m, double d)
VP_EXPORT int | VpSqrt (Real *y, Real *x)
VP_EXPORT int | VpMidRound (Real *y, unsigned short f, ssize_t nf)
VP_EXPORT int | VpLeftRound (Real *y, unsigned short f, ssize_t nf)
VP_EXPORT int | VpActiveRound (Real *y, Real *x, unsigned short f, ssize_t nf)
VP_EXPORT void | VpFrac (Real *y, Real *x)
VP_EXPORT int | VpPower (Real *y, Real *x, SIGNED_VALUE n)

## Variables
VALUE | rb_cBigDecimal
VALUE | rb_mBigMath
static ID | id_BigDecimal_exception_mode
static ID | id_BigDecimal_rounding_mode
static ID | id_BigDecimal_precision_limit
static ID | id_up
static ID | id_down
static ID | id_truncate
static ID | id_half_up
static ID | id_default
static ID | id_half_down
static ID | id_half_even
static ID | id_banker
static ID | id_ceiling
static ID | id_ceil
static ID | id_floor
static ID | id_to_r
static ID | id_eq
static const rb_data_type_t | BigDecimal_data_type
static Real * | VpConstOne
static Real * | VpPt5
volatile const double | gZero_ABCED9B1_CE73__00400511F31D = 0.0
volatile const double | gOne_ABCED9B4_CE73__00400511F31D = 1.0

## Macro Definition Documentation

#define BASE RMPD_BASE

Definition at line 69 of file bigdecimal.c.

Referenced by VpAddAbs(), VpDivd(), VpDtoV(), VpInit(), VpMidRound(), VpMult(), VpRdup(), VpSqrt(), VpSubAbs(), VpToFString(), and VpVtoD().

#define BASE1 (BASE/10)

Definition at line 72 of file bigdecimal.c.

Referenced by VpExponent10(), VpInit(), VpInternalRound(), VpSzMantissa(), VpToFString(), and VpToString().

#define BASE_FIG RMPD_COMPONENT_FIGURES

Definition at line 68 of file bigdecimal.c.

Referenced by AddExponent(), BigDecimal_to_f(), VpAddSub(), VpAlloc(), VpAsgn(), VpCtoV(), VpDivd(), VpExponent10(), VpInit(), VpLeftRound(), VpLimitRound(), VpMidRound(), VpMult(), VpNumOfChars(), VpPower(), VpSqrt(), VpToFString(), VpToString(), and VpVtoD().

#define BigMath_exp | ( |  | x,
|  |  | n
| ) |  | BigMath_s_exp(rb_mBigMath, (x), (n))

Definition at line 2011 of file bigdecimal.c.

Referenced by rmpd_power_by_big_decimal().

#define BigMath_log | ( |  | x,
|  |  | n
| ) |  | BigMath_s_log(rb_mBigMath, (x), (n))

Definition at line 2012 of file bigdecimal.c.

Referenced by rmpd_power_by_big_decimal().

#define DBLE_FIG (DBL_DIG+1) /* figure of double */

Definition at line 75 of file bigdecimal.c.

Referenced by VpInit(), VpSqrt(), and VpVtoD().

#define DoSomeOne | ( |  | x,
|  |  | y,
|  |  | f
| ) |  | rb_num_coerce_bin(x,y,f)

Definition at line 108 of file bigdecimal.c.

Referenced by BigDecimal_add(), BigDecimal_div2(), BigDecimal_divide(), BigDecimal_divmod(), BigDecimal_divremain(), BigDecimal_mod(), BigDecimal_mult(), and BigDecimal_sub().

#define ENTER | ( |  | n) |  | volatile VALUE RB_UNUSED_VAR(vStack[n]);int iStack=0

Definition at line 63 of file bigdecimal.c.

Referenced by BigDecimal_abs(), BigDecimal_add(), BigDecimal_add2(), BigDecimal_ceil(), BigDecimal_coerce(), BigDecimal_div(), BigDecimal_div2(), BigDecimal_divide(), BigDecimal_divmod(), BigDecimal_divremain(), BigDecimal_DoDivmod(), BigDecimal_dump(), BigDecimal_fix(), BigDecimal_floor(), BigDecimal_frac(), BigDecimal_hash(), BigDecimal_inspect(), BigDecimal_load(), BigDecimal_mod(), BigDecimal_mult(), BigDecimal_mult2(), BigDecimal_neg(), BigDecimal_power(), BigDecimal_prec(), BigDecimal_round(), BigDecimal_split(), BigDecimal_sqrt(), BigDecimal_sub(), BigDecimal_sub2(), BigDecimal_to_f(), BigDecimal_to_i(), BigDecimal_to_s(), BigDecimal_truncate(), and BigDecimalCmp().

#define GUARD_OBJ | ( |  | p,
|  |  | y
| ) |  | {p=y;SAVE(p);}

Definition at line 66 of file bigdecimal.c.

Referenced by BigDecimal_abs(), BigDecimal_add(), BigDecimal_add2(), BigDecimal_ceil(), BigDecimal_coerce(), BigDecimal_div2(), BigDecimal_divide(), BigDecimal_divremain(), BigDecimal_DoDivmod(), BigDecimal_dump(), BigDecimal_fix(), BigDecimal_floor(), BigDecimal_frac(), BigDecimal_hash(), BigDecimal_inspect(), BigDecimal_load(), BigDecimal_mult(), BigDecimal_mult2(), BigDecimal_neg(), BigDecimal_power(), BigDecimal_prec(), BigDecimal_round(), BigDecimal_split(), BigDecimal_sqrt(), BigDecimal_sub(), BigDecimal_sub2(), BigDecimal_to_f(), BigDecimal_to_i(), BigDecimal_to_s(), BigDecimal_truncate(), and BigDecimalCmp().

#define HALF_BASE (BASE/2)

Definition at line 71 of file bigdecimal.c.

Referenced by VpInit().

#define is_positive | ( |  | x) |  | (!is_negative(x))

Definition at line 2035 of file bigdecimal.c.

Referenced by BigDecimal_power().

#define maxnr 100UL /* Maximum iterations for calcurating sqrt. */

Definition at line 3247 of file bigdecimal.c.

Referenced by VpSqrt().

#define MemCmp | ( |  | x,
|  |  | y,
|  |  | z
| ) |  | memcmp(x,y,z)

Definition at line 3251 of file bigdecimal.c.

#define NDEBUG

Definition at line 23 of file bigdecimal.c.

#define PUSH | ( |  | x) |  | vStack[iStack++] = (VALUE)(x);

Definition at line 64 of file bigdecimal.c.

Referenced by yaml_document_add_mapping(), yaml_document_add_scalar(), yaml_document_add_sequence(), yaml_document_append_mapping_pair(), yaml_document_append_sequence_item(), yaml_document_initialize(), yaml_document_start_event_initialize(), yaml_emitter_append_tag_directive(), yaml_emitter_emit_block_mapping_key(), yaml_emitter_emit_block_mapping_value(), yaml_emitter_emit_block_sequence_item(), yaml_emitter_emit_document_content(), yaml_emitter_emit_flow_mapping_key(), yaml_emitter_emit_flow_mapping_value(), yaml_emitter_emit_flow_sequence_item(), yaml_emitter_increase_indent(), yaml_parser_append_tag_directive(), yaml_parser_fetch_stream_start(), yaml_parser_increase_flow_level(), yaml_parser_load_mapping(), yaml_parser_load_scalar(), yaml_parser_load_sequence(), yaml_parser_parse_block_mapping_key(), yaml_parser_parse_block_mapping_value(), yaml_parser_parse_block_sequence_entry(), yaml_parser_parse_document_start(), yaml_parser_parse_flow_mapping_key(), yaml_parser_parse_flow_mapping_value(), yaml_parser_parse_flow_sequence_entry(), yaml_parser_parse_flow_sequence_entry_mapping_key(), yaml_parser_parse_flow_sequence_entry_mapping_value(), yaml_parser_parse_indentless_sequence_entry(), yaml_parser_process_directives(), yaml_parser_register_anchor(), and yaml_parser_roll_indent().

#define RBIGNUM_ZERO_P | ( |  | x) |  |

Value:
(RBIGNUM_LEN(x) == 0 || \
(RBIGNUM_DIGITS(x)[0] == 0 && \
(RBIGNUM_LEN(x) == 1 || bigzero_p(x))))

Definition at line 79 of file bigdecimal.c.

Referenced by BigMath_s_log().

#define RMPD_PRECISION_LIMIT_DEFAULT ((size_t)0)

Definition at line 3353 of file bigdecimal.c.

Referenced by VpGetPrecLimit().

#define rmpd_set_thread_local_exception_mode | ( |  | mode) |  |

Value:
rb_thread_local_aset( \
rb_thread_current(), \
id_BigDecimal_exception_mode, \
INT2FIX((int)(mode)) \
)

Definition at line 3314 of file bigdecimal.c.

Referenced by VpGetException(), and VpSetException().

#define rmpd_set_thread_local_precision_limit | ( |  | limit) |  |

Value:
rb_thread_local_aset( \
rb_thread_current(), \
id_BigDecimal_precision_limit, \
SIZET2NUM(limit) \
)

Definition at line 3347 of file bigdecimal.c.

Referenced by VpGetPrecLimit(), and VpSetPrecLimit().

#define rmpd_set_thread_local_rounding_mode | ( |  | mode) |  |

Value:
rb_thread_local_aset( \
rb_thread_current(), \
id_BigDecimal_rounding_mode, \
INT2FIX((int)(mode)) \
)

Definition at line 3384 of file bigdecimal.c.

Referenced by VpGetRoundMode(), and VpSetRoundMode().

#define RRATIONAL_NEGATIVE_P | ( |  | x) |  | RTEST(rb_funcall((x), '<', 1, INT2FIX(0)))

Definition at line 102 of file bigdecimal.c.

Referenced by BigMath_s_log().

#define RRATIONAL_ZERO_P | ( |  | x) |  |

Value:
(FIXNUM_P(RRATIONAL(x)->num) && \
FIX2LONG(RRATIONAL(x)->num) == 0)

Definition at line 97 of file bigdecimal.c.

Referenced by BigMath_s_log().

#define SAVE | ( |  | p) |  | PUSH(p->obj);

Definition at line 65 of file bigdecimal.c.

Referenced by BigDecimal_add(), BigDecimal_div(), BigDecimal_divide(), BigDecimal_divmod(), BigDecimal_divremain(), BigDecimal_DoDivmod(), BigDecimal_mod(), BigDecimal_mult(), BigDecimal_sub(), and BigDecimalCmp().

#define StrCmp | ( |  | x,
|  |  | y
| ) |  | strcmp(x,y)

Definition at line 3252 of file bigdecimal.c.

Referenced by VpAlloc().

#define VpAllocReal | ( |  | prec) |  | (Real *)VpMemAlloc(offsetof(Real, frac) + (prec) * sizeof(BDIGIT))

Definition at line 574 of file bigdecimal.c.

Referenced by VpAlloc().

#define VpReallocReal | ( |  | ptr,
|  |  | prec
| ) |  | (Real *)VpMemRealloc((ptr), offsetof(Real, frac) + (prec) * sizeof(BDIGIT))

Definition at line 575 of file bigdecimal.c.

Referenced by VpCopy().

## Function Documentation

static int AddExponent | ( | Real * | a,
|  | SIGNED_VALUE | n
| ) |  |
| static

Definition at line 3733 of file bigdecimal.c.

References BASE_FIG, Real::exponent, SIGNED_VALUE, VP_EXCEPTION_OVERFLOW, VP_EXCEPTION_UNDERFLOW, VpException(), VpGetSign, VpSetInf, and VpSetZero.

Referenced by VpDivd(), VpMult(), VpNmlz(), VpRdup(), and VpSetPTR().

static VALUE BigDecimal_abs | ( | VALUE | self) |  |
| static

Definition at line 1542 of file bigdecimal.c.

References c, ENTER, GetVpValue(), GUARD_OBJ, Real::Prec, ToValue(), VpAsgn(), VpBaseFig, VpChangeSign, and VpCreateRbObject().

Referenced by BigDecimal_power(), and Init_bigdecimal().

static VALUE BigDecimal_add | ( | VALUE | self,
|  | VALUE | r
| ) |  |
| static

Definition at line 836 of file bigdecimal.c.

References c, DBL_DIG, DoSomeOne, ENTER, GetAddSubPrec(), GetVpValue(), GetVpValueWithPrec(), GUARD_OBJ, Real::obj, Real::Prec, RB_TYPE_P, SAVE, T_FLOAT, T_RATIONAL, ToValue(), VpAddSub(), VpBaseFig, VpCreateRbObject(), VpGetSign, VpIsNaN, and VpSetInf.

Referenced by BigDecimal_add2(), BigMath_s_exp(), BigMath_s_log(), and Init_bigdecimal().

static VALUE BigDecimal_add2 | ( | VALUE | self,
|  | VALUE | b,
|  | VALUE | n
| ) |  |
| static

Definition at line 1485 of file bigdecimal.c.

References BigDecimal_add(), c, cv, ENTER, GetPositiveInt(), GetVpValue(), GUARD_OBJ, SIGNED_VALUE, ToValue(), VpGetRoundMode(), VpLeftRound(), and VpSetPrecLimit().

Referenced by Init_bigdecimal().

static VALUE BigDecimal_ceil | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |
| static

Definition at line 1780 of file bigdecimal.c.

References BigDecimal_to_i(), c, Check_Type, ENTER, FIX2INT, GetVpValue(), GUARD_OBJ, Real::Prec, rb_scan_args(), T_FIXNUM, ToValue(), VP_ROUND_CEIL, VpActiveRound(), VpBaseFig, VpCreateRbObject(), and VpSetPrecLimit().

Referenced by Init_bigdecimal().

static void BigDecimal_check_num | ( | Real * | p) |  |
| static

Definition at line 625 of file bigdecimal.c.

References VP_EXCEPTION_INFINITY, VP_EXCEPTION_NaN, VpException(), VpIsNaN, VpIsNegInf, and VpIsPosInf.

Referenced by BigDecimal_to_i(), and BigDecimal_to_r().

static VALUE BigDecimal_coerce | ( | VALUE | self,
|  | VALUE | other
| ) |  |
| static

Definition at line 781 of file bigdecimal.c.

References BigDecimal_to_f(), DATA_PTR, ENTER, GetVpValue(), GetVpValueWithPrec(), GUARD_OBJ, Real::obj, Real::Prec, rb_assoc_new(), RB_TYPE_P, T_FLOAT, T_RATIONAL, and VpBaseFig.

Referenced by Init_bigdecimal().

static VALUE BigDecimal_comp | ( | VALUE | self,
|  | VALUE | r
| ) |  |
| static

Definition at line 1042 of file bigdecimal.c.

References BigDecimalCmp().

Referenced by Init_bigdecimal().

static void BigDecimal_delete | ( | void * | pv) |  |
| static

Definition at line 138 of file bigdecimal.c.

References VpFree().

static VALUE BigDecimal_div | ( | VALUE | self,
|  | VALUE | r
| ) |  |
| static

Definition at line 1229 of file bigdecimal.c.

References BDIGIT, BDIGIT_DBL, BigDecimal_divide(), c, div, ENTER, Real::frac, NULL, Real::Prec, SAVE, ToValue(), VpBaseVal, VpHasVal, and VpInternalRound().

Referenced by BigDecimal_div2(), and Init_bigdecimal().

static VALUE BigDecimal_div2 | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |
| static

Definition at line 1449 of file bigdecimal.c.

References BigDecimal_div(), BigDecimal_DoDivmod(), BigDecimal_to_i(), cv, div, DoSomeOne, ENTER, GetPositiveInt(), GetVpValue(), GUARD_OBJ, mod, NULL, Real::Prec, rb_intern, rb_scan_args(), SIGNED_VALUE, ToValue(), VpBaseFig, VpCreateRbObject(), VpDivd(), VpGetRoundMode(), VpLeftRound(), and VpSetPrecLimit().

Referenced by BigMath_s_exp(), BigMath_s_log(), GetVpValueWithPrec(), and Init_bigdecimal().

static VALUE BigDecimal_divide | ( | Real ** | c,
|  | Real ** | res,
|  | Real ** | div,
|  | VALUE | self,
|  | VALUE | r
| ) |  |
| static

Definition at line 1178 of file bigdecimal.c.

References DBL_DIG, DoSomeOne, ENTER, Real::exponent, GetVpValue(), GetVpValueWithPrec(), GUARD_OBJ, Real::Prec, RB_TYPE_P, SAVE, T_FLOAT, T_RATIONAL, vabs, VpBaseFig, VpCreateRbObject(), and VpDivd().

Referenced by BigDecimal_div().

static VALUE BigDecimal_divmod | ( | VALUE | self,
|  | VALUE | r
| ) |  |
| static

Definition at line 1433 of file bigdecimal.c.

References BigDecimal_DoDivmod(), div, DoSomeOne, ENTER, mod, NULL, rb_assoc_new(), rb_intern, SAVE, and ToValue().

Referenced by Init_bigdecimal().

static VALUE BigDecimal_divremain | ( | VALUE | self,
|  | VALUE | r,
|  | Real ** | dv,
|  | Real ** | rv
| ) |  |
| static

Definition at line 1354 of file bigdecimal.c.

References c, DBL_DIG, DoSomeOne, ENTER, f, GetVpValue(), GetVpValueWithPrec(), GUARD_OBJ, Real::MaxPrec, NULL, Real::Prec, rb_intern, RB_TYPE_P, SAVE, T_FLOAT, T_RATIONAL, VP_ROUND_DOWN, VpActiveRound(), VpAddSub(), VpBaseFig, VpCreateRbObject(), VpDivd(), VpFrac(), and VpMult().

Referenced by BigDecimal_remainder().

static VALUE BigDecimal_DoDivmod | ( | VALUE | self,
|  | VALUE | r,
|  | Real ** | div,
|  | Real ** | mod
| ) |  |
| static

Definition at line 1253 of file bigdecimal.c.

References c, DBL_DIG, ENTER, Real::exponent, GetAddSubPrec(), GetVpValue(), GetVpValueWithPrec(), GUARD_OBJ, NULL, Real::Prec, Qfalse, Qtrue, rb_eZeroDivError, rb_raise(), RB_TYPE_P, SAVE, SIGNED_VALUE, T_FLOAT, T_RATIONAL, vabs, VP_ROUND_DOWN, VpActiveRound(), VpAddSub(), VpBaseFig, VpCreateRbObject(), VpDivd(), VpGetSign, VpIsInf, VpIsNaN, VpIsZero, VpMult(), VpOne(), and VpSetInf.

Referenced by BigDecimal_div2(), BigDecimal_divmod(), and BigDecimal_mod().

static VALUE BigDecimal_double_fig | ( | VALUE | self) |  |
| static

Definition at line 285 of file bigdecimal.c.

References INT2FIX, and VpDblFig.

Referenced by Init_bigdecimal().

static VALUE BigDecimal_dump | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |
| static

Definition at line 350 of file bigdecimal.c.

References ENTER, GetVpValue(), GUARD_OBJ, PRIuSIZE, rb_scan_args(), rb_str_new(), rb_str_resize(), RSTRING_PTR, strlen(), VpBaseFig, VpMaxPrec, VpNumOfChars(), and VpToString().

Referenced by Init_bigdecimal().

static VALUE BigDecimal_eq | ( | VALUE | self,
|  | VALUE | r
| ) |  |
| static

Definition at line 1058 of file bigdecimal.c.

References BigDecimalCmp().

Referenced by BigDecimal_power(), and Init_bigdecimal().

static VALUE BigDecimal_exponent | ( | VALUE | self) |  |
| static

Definition at line 1968 of file bigdecimal.c.

References GetVpValue(), INT2NUM, and VpExponent10().

Referenced by Init_bigdecimal().

static VALUE BigDecimal_fix | ( | VALUE | self) |  |
| static

Definition at line 1583 of file bigdecimal.c.

References c, ENTER, GetVpValue(), GUARD_OBJ, Real::Prec, ToValue(), VP_ROUND_DOWN, VpActiveRound(), VpBaseFig, and VpCreateRbObject().

Referenced by Init_bigdecimal().

static VALUE BigDecimal_floor | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |
| static

Definition at line 1733 of file bigdecimal.c.

References BigDecimal_to_i(), c, Check_Type, ENTER, FIX2INT, GetVpValue(), GUARD_OBJ, Real::Prec, rb_scan_args(), T_FIXNUM, ToValue(), VP_ROUND_FLOOR, VpActiveRound(), VpBaseFig, VpCreateRbObject(), and VpSetPrecLimit().

Referenced by Init_bigdecimal().

static VALUE BigDecimal_frac | ( | VALUE | self) |  |
| static

Definition at line 1702 of file bigdecimal.c.

References c, ENTER, GetVpValue(), GUARD_OBJ, Real::Prec, ToValue(), VpBaseFig, VpCreateRbObject(), and VpFrac().

Referenced by Init_bigdecimal().

static VALUE BigDecimal_ge | ( | VALUE | self,
|  | VALUE | r
| ) |  |
| static

Definition at line 1110 of file bigdecimal.c.

References BigDecimalCmp().

Referenced by Init_bigdecimal().

static VALUE BigDecimal_global_new | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |
| static

Definition at line 2469 of file bigdecimal.c.

References BigDecimal_new(), NULL, Real::obj, rb_cBigDecimal, ToValue(), TypedData_Wrap_Struct, and VpCopy().

Referenced by Init_bigdecimal().

static VALUE BigDecimal_gt | ( | VALUE | self,
|  | VALUE | r
| ) |  |
| static

Definition at line 1097 of file bigdecimal.c.

References BigDecimalCmp().

Referenced by Init_bigdecimal().

static VALUE BigDecimal_hash | ( | VALUE | self) |  |
| static

Definition at line 321 of file bigdecimal.c.

References BDIGIT, ENTER, Real::exponent, Real::frac, GetVpValue(), GUARD_OBJ, hash(), INT2FIX, p, Real::Prec, rb_memhash(), and Real::sign.

Referenced by Init_bigdecimal().

static VALUE BigDecimal_initialize | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |
| static

Definition at line 2389 of file bigdecimal.c.

References BigDecimal_new(), DATA_PTR, Real::obj, rb_check_typeddata(), ToValue(), VpCopy(), and VpFree().

Referenced by Init_bigdecimal().

static VALUE BigDecimal_initialize_copy | ( | VALUE | self,
|  | VALUE | other
| ) |  |
| static

Definition at line 2411 of file bigdecimal.c.

References DATA_PTR, rb_check_typeddata(), and VpCopy().

Referenced by Init_bigdecimal().

static VALUE BigDecimal_inspect | ( | VALUE | self) |  |
| static

Definition at line 1985 of file bigdecimal.c.

References ENTER, GetVpValue(), GUARD_OBJ, PRIuSIZE, PRIxVALUE, rb_str_new(), rb_str_resize(), RSTRING_PTR, strlen(), VpBaseFig, VpMaxPrec, VpNumOfChars(), VpPrec, and VpToString().

Referenced by Init_bigdecimal().

static VALUE BigDecimal_IsFinite | ( | VALUE | self) |  |
| static

Definition at line 616 of file bigdecimal.c.

References GetVpValue(), p, Qfalse, Qtrue, VpIsInf, and VpIsNaN.

Referenced by Init_bigdecimal().

static VALUE BigDecimal_IsInfinite | ( | VALUE | self) |  |
| static

Definition at line 606 of file bigdecimal.c.

References GetVpValue(), INT2FIX, p, Qnil, VpIsNegInf, and VpIsPosInf.

Referenced by Init_bigdecimal().

static VALUE BigDecimal_IsNaN | ( | VALUE | self) |  |
| static

Definition at line 595 of file bigdecimal.c.

References GetVpValue(), p, Qfalse, Qtrue, and VpIsNaN.

Referenced by Init_bigdecimal().

static VALUE BigDecimal_le | ( | VALUE | self,
|  | VALUE | r
| ) |  |
| static

Definition at line 1084 of file bigdecimal.c.

References BigDecimalCmp().

Referenced by Init_bigdecimal().

static VALUE BigDecimal_limit | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |
| static

Definition at line 2490 of file bigdecimal.c.

References Check_Type, FIX2INT, INT2NUM, Qnil, rb_eArgError, rb_raise(), rb_scan_args(), T_FIXNUM, VpGetPrecLimit(), and VpSetPrecLimit().

Referenced by Init_bigdecimal().

static VALUE BigDecimal_load | ( | VALUE | self,
|  | VALUE | str
| ) |  |
| static

Definition at line 372 of file bigdecimal.c.

References ENTER, GUARD_OBJ, ISDIGIT, Real::MaxPrec, rb_eTypeError, rb_raise(), RSTRING_PTR, SafeStringValue, ToValue(), VpBaseFig, and VpNewRbClass().

Referenced by Init_bigdecimal().

static VALUE BigDecimal_lt | ( | VALUE | self,
|  | VALUE | r
| ) |  |
| static

Definition at line 1071 of file bigdecimal.c.

References BigDecimalCmp().

Referenced by Init_bigdecimal().

static size_t BigDecimal_memsize | ( | const void * | ptr) |  |
| static

Definition at line 144 of file bigdecimal.c.

References BDIGIT, and Real::MaxPrec.

static VALUE BigDecimal_mod | ( | VALUE | self,
|  | VALUE | r
| ) |  |
| static

Definition at line 1341 of file bigdecimal.c.

References BigDecimal_DoDivmod(), div, DoSomeOne, ENTER, mod, NULL, SAVE, and ToValue().

Referenced by Init_bigdecimal().

static VALUE BigDecimal_mode | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |
| static

Definition at line 471 of file bigdecimal.c.

References check_rounding_mode(), Check_Type, f, FIX2INT, INT2FIX, NIL_P, Qfalse, Qnil, Qtrue, rb_eArgError, rb_eTypeError, rb_raise(), rb_scan_args(), T_FIXNUM, val, VP_EXCEPTION_ALL, VP_EXCEPTION_INFINITY, VP_EXCEPTION_NaN, VP_EXCEPTION_UNDERFLOW, VP_EXCEPTION_ZERODIVIDE, VP_ROUND_MODE, VpGetException(), VpGetRoundMode(), VpSetException(), and VpSetRoundMode().

Referenced by Init_bigdecimal().

static VALUE BigDecimal_mult | ( | VALUE | self,
|  | VALUE | r
| ) |  |
| static

Definition at line 1151 of file bigdecimal.c.

References c, DBL_DIG, DoSomeOne, ENTER, GetVpValue(), GetVpValueWithPrec(), GUARD_OBJ, Real::Prec, RB_TYPE_P, SAVE, T_FLOAT, T_RATIONAL, ToValue(), VpBaseFig, VpCreateRbObject(), and VpMult().

Referenced by BigDecimal_mult2(), BigMath_s_exp(), BigMath_s_log(), and Init_bigdecimal().

static VALUE BigDecimal_mult2 | ( | VALUE | self,
|  | VALUE | b,
|  | VALUE | n
| ) |  |
| static

Definition at line 1519 of file bigdecimal.c.

References BigDecimal_mult(), c, cv, ENTER, GetPositiveInt(), GetVpValue(), GUARD_OBJ, SIGNED_VALUE, ToValue(), VpGetRoundMode(), VpLeftRound(), and VpSetPrecLimit().

Referenced by BigMath_s_exp(), BigMath_s_log(), Init_bigdecimal(), and rmpd_power_by_big_decimal().

static VALUE BigDecimal_neg | ( | VALUE | self) |  |
| static

Definition at line 1125 of file bigdecimal.c.

References c, ENTER, GetVpValue(), GUARD_OBJ, Real::Prec, ToValue(), VpAsgn(), VpBaseFig, and VpCreateRbObject().

Referenced by Init_bigdecimal().

static Real * BigDecimal_new | ( | int | argc,
|  | VALUE * | argv
| ) |  |
| static

Definition at line 2421 of file bigdecimal.c.

References CLASS_OF, DATA_PTR, DBL_DIG, GetPositiveInt(), GetVpValue(), GetVpValueWithPrec(), is_kind_of_BigDecimal(), NIL_P, rb_class2name(), rb_eArgError, rb_raise(), rb_scan_args(), RSTRING_PTR, StringValueCStr, T_BIGNUM, T_DATA, T_FIXNUM, T_FLOAT, T_RATIONAL, T_STRING, TYPE, and VpAlloc().

Referenced by BigDecimal_global_new(), and BigDecimal_initialize().

static VALUE BigDecimal_nonzero | ( | VALUE | self) |  |
| static

Definition at line 1032 of file bigdecimal.c.

References GetVpValue(), Qnil, and VpIsZero.

Referenced by Init_bigdecimal().

static VALUE BigDecimal_power | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |
| static

Definition at line 2131 of file bigdecimal.c.

References BigDecimal_abs(), BigDecimal_eq(), BigDecimal_round(), BigDecimal_to_i(), DATA_PTR, DBL_DIG, ENTER, FIX2INT, GetVpValue(), GetVpValueWithPrec(), GUARD_OBJ, INT2FIX, is_even(), is_integer(), is_kind_of_BigDecimal(), is_negative(), is_one(), is_positive, is_zero(), NIL_P, NULL, NUM2SSIZET, Real::obj, Real::Prec, rb_eMathDomainError, rb_eTypeError, rb_funcall(), RB_GC_GUARD, rb_obj_classname(), rb_raise(), rb_scan_args(), RB_TYPE_P, RFLOAT_VALUE, rmpd_power_by_big_decimal(), round(), RRATIONAL, RTEST, SIGNED_VALUE, T_BIGNUM, T_DATA, T_FIXNUM, T_FLOAT, T_RATIONAL, ToValue(), TYPE, VpBaseFig, VpCreateRbObject(), VpGetSign, VpIsDef, VpIsInf, VpIsNaN, VpIsZero, VpPower(), VpSetInf, VpSetNaN, VpSetNegInf, VpSetPosInf, and zero().

Referenced by BigDecimal_power_op(), and Init_bigdecimal().

static VALUE BigDecimal_power_op | ( | VALUE | self,
|  | VALUE | exp
| ) |  |
| static

Definition at line 2357 of file bigdecimal.c.

References BigDecimal_power().

Referenced by Init_bigdecimal().

static VALUE BigDecimal_prec | ( | VALUE | self) |  |
| static

Definition at line 300 of file bigdecimal.c.

References ENTER, GetVpValue(), GUARD_OBJ, INT2NUM, Real::MaxPrec, p, Real::Prec, rb_assoc_new(), and VpBaseFig.

Referenced by Init_bigdecimal().

static VALUE BigDecimal_remainder | ( | VALUE | self,
|  | VALUE | r
| ) |  |
| static

Definition at line 1404 of file bigdecimal.c.

References BigDecimal_divremain(), f, and ToValue().

Referenced by Init_bigdecimal().

static VALUE BigDecimal_round | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |
| static

Definition at line 1617 of file bigdecimal.c.

References BigDecimal_to_i(), c, check_rounding_mode(), Check_Type, ENTER, FIX2INT, GetVpValue(), GUARD_OBJ, Real::Prec, rb_scan_args(), T_FIXNUM, ToValue(), VpActiveRound(), VpBaseFig, VpCreateRbObject(), VpGetRoundMode(), and VpSetPrecLimit().

Referenced by BigDecimal_power(), BigMath_s_exp(), and Init_bigdecimal().

static VALUE BigDecimal_s_allocate | ( | VALUE | klass) |  |
| static

Definition at line 2363 of file bigdecimal.c.

References NULL, Real::obj, and VpNewRbClass().

Referenced by Init_bigdecimal().

static VALUE BigDecimal_save_exception_mode | ( | VALUE | self) |  |
| static

Definition at line 2550 of file bigdecimal.c.

References Qnil, rb_jump_tag(), rb_protect(), rb_yield(), VpGetException(), and VpSetException().

Referenced by Init_bigdecimal().

static VALUE BigDecimal_save_limit | ( | VALUE | self) |  |
| static

Definition at line 2600 of file bigdecimal.c.

References Qnil, rb_jump_tag(), rb_protect(), rb_yield(), VpGetPrecLimit(), and VpSetPrecLimit().

Referenced by Init_bigdecimal().

static VALUE BigDecimal_save_rounding_mode | ( | VALUE | self) |  |
| static

Definition at line 2575 of file bigdecimal.c.

References Qnil, rb_jump_tag(), rb_protect(), rb_yield(), VpGetRoundMode(), and VpSetRoundMode().

Referenced by Init_bigdecimal().

static VALUE BigDecimal_sign | ( | VALUE | self) |  |
| static

Definition at line 2525 of file bigdecimal.c.

References GetVpValue(), INT2FIX, and Real::sign.

Referenced by Init_bigdecimal().

static VALUE BigDecimal_split | ( | VALUE | self) |  |
| static

Definition at line 1931 of file bigdecimal.c.

References ENTER, GetVpValue(), GUARD_OBJ, INT2FIX, INT2NUM, memmove(), rb_ary_new2(), rb_ary_push(), rb_str_new(), rb_str_resize(), RSTRING_PTR, strlen(), VpExponent10(), VpNumOfChars(), and VpSzMantissa().

Referenced by BigDecimal_to_i(), BigDecimal_to_r(), and Init_bigdecimal().

static VALUE BigDecimal_sqrt | ( | VALUE | self,
|  | VALUE | nFig
| ) |  |
| static

Definition at line 1564 of file bigdecimal.c.

References c, ENTER, GetPositiveInt(), GetVpValue(), GUARD_OBJ, Real::Prec, ToValue(), VpBaseFig, VpCreateRbObject(), VpDblFig, and VpSqrt().

Referenced by Init_bigdecimal().

static VALUE BigDecimal_sub | ( | VALUE | self,
|  | VALUE | r
| ) |  |
| static

Definition at line 890 of file bigdecimal.c.

References c, DBL_DIG, DoSomeOne, ENTER, GetAddSubPrec(), GetVpValue(), GetVpValueWithPrec(), GUARD_OBJ, Real::obj, Real::Prec, RB_TYPE_P, SAVE, T_FLOAT, T_RATIONAL, ToValue(), VpAddSub(), VpBaseFig, VpCreateRbObject(), VpGetSign, VpIsNaN, and VpSetInf.

Referenced by BigDecimal_sub2(), BigMath_s_log(), and Init_bigdecimal().

static VALUE BigDecimal_sub2 | ( | VALUE | self,
|  | VALUE | b,
|  | VALUE | n
| ) |  |
| static

Definition at line 1502 of file bigdecimal.c.

References BigDecimal_sub(), c, cv, ENTER, GetPositiveInt(), GetVpValue(), GUARD_OBJ, SIGNED_VALUE, ToValue(), VpGetRoundMode(), VpLeftRound(), and VpSetPrecLimit().

Referenced by Init_bigdecimal().

static VALUE BigDecimal_to_f | ( | VALUE | self) |  |
| static

Definition at line 688 of file bigdecimal.c.

References BASE_FIG, buf, DBL_MAX_10_EXP, DBL_MIN_10_EXP, ENTER, errno, GetVpValue(), GUARD_OBJ, p, rb_float_new(), rb_str_new(), RSTRING_PTR, Real::sign, SIGNED_VALUE, strtod, VP_EXCEPTION_OVERFLOW, VP_EXCEPTION_UNDERFLOW, VpException(), VpGetDoubleNegInf(), VpGetDoublePosInf(), VpNumOfChars(), VpToString(), and VpVtoD().

Referenced by BigDecimal_coerce(), and Init_bigdecimal().

static VALUE BigDecimal_to_i | ( | VALUE | self) |  |
| static

Definition at line 643 of file bigdecimal.c.

References BDIGIT_DBL_SIGNED, BigDecimal_check_num(), BigDecimal_split(), ENTER, Real::frac, GetVpValue(), GUARD_OBJ, INT2FIX, LONG2NUM, p, RARRAY_PTR, rb_eFloatDomainError, rb_funcall(), rb_intern, rb_raise(), RB_TYPE_P, RSTRING_LEN, T_FLOAT, VpBaseFig, VpExponent10(), and VpGetSign.

Referenced by BigDecimal_ceil(), BigDecimal_div2(), BigDecimal_floor(), BigDecimal_power(), BigDecimal_round(), BigDecimal_truncate(), and Init_bigdecimal().

static VALUE BigDecimal_to_r | ( | VALUE | self) |  |
| static

Definition at line 735 of file bigdecimal.c.

References BigDecimal_check_num(), BigDecimal_split(), GetVpValue(), INT2FIX, p, RARRAY_PTR, rb_funcall(), rb_intern, rb_Rational(), rb_Rational1, RSTRING_LEN, VpExponent10(), and VpGetSign.

Referenced by Init_bigdecimal().

static VALUE BigDecimal_to_s | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |
| static

Definition at line 1840 of file bigdecimal.c.

References ENTER, f, GetPositiveInt(), GetVpValue(), GUARD_OBJ, ISDIGIT, ISSPACE, rb_scan_args(), rb_str_new(), rb_str_resize(), RB_TYPE_P, RSTRING_PTR, SafeStringValue, strlen(), T_STRING, VpNumOfChars(), VpToFString(), and VpToString().

Referenced by Init_bigdecimal().

static VALUE BigDecimal_truncate | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |
| static

Definition at line 1673 of file bigdecimal.c.

References BigDecimal_to_i(), c, Check_Type, ENTER, FIX2INT, GetVpValue(), GUARD_OBJ, Real::Prec, rb_scan_args(), T_FIXNUM, ToValue(), VP_ROUND_DOWN, VpActiveRound(), VpBaseFig, VpCreateRbObject(), and VpSetPrecLimit().

Referenced by Init_bigdecimal().

static VALUE BigDecimal_uplus | ( | VALUE | self) |  |
| static

Definition at line 813 of file bigdecimal.c.

Referenced by Init_bigdecimal().

static VALUE BigDecimal_version | ( | VALUE | self) |  |
| static

Definition at line 114 of file bigdecimal.c.

References rb_str_new2.

Referenced by Init_bigdecimal().

static VALUE BigDecimal_zero | ( | VALUE | self) |  |
| static

Definition at line 1024 of file bigdecimal.c.

References GetVpValue(), Qfalse, Qtrue, and VpIsZero.

Referenced by Init_bigdecimal().

static VALUE BigDecimalCmp | ( | VALUE | self,
|  | VALUE | r,
|  | char | op
| ) |  |
| static

Definition at line 929 of file bigdecimal.c.

References DBL_DIG, ENTER, f, GetVpValue(), GetVpValueWithPrec(), GUARD_OBJ, INT2FIX, is_kind_of_BigDecimal(), NULL, Real::Prec, Qfalse, Qnil, Qtrue, rb_bug(), rb_intern, rb_num_coerce_cmp(), rb_num_coerce_relop(), RTEST, SAVE, SIGNED_VALUE, T_BIGNUM, T_DATA, T_FIXNUM, T_FLOAT, T_RATIONAL, TYPE, UNREACHABLE, VpBaseFig, and VpComp().

Referenced by BigDecimal_comp(), BigDecimal_eq(), BigDecimal_ge(), BigDecimal_gt(), BigDecimal_le(), and BigDecimal_lt().

static VALUE BigMath_s_exp | ( | VALUE | klass,
|  | VALUE | x,
|  | VALUE | vprec
| ) |  |
| static

Definition at line 2621 of file bigdecimal.c.

References argv, BigDecimal_add(), BigDecimal_div2(), BigDecimal_mult(), BigDecimal_mult2(), BigDecimal_round(), cannot_be_coerced_into_BigDecimal(), DATA_PTR, DBL_DIG, GetVpValue(), GetVpValueWithPrec(), i, INT2NUM, is_kind_of_BigDecimal(), isinf(), isnan, NULL, NUM2SSIZET, Real::obj, one(), rb_eArgError, RB_GC_GUARD, rb_raise(), RFLOAT_VALUE, rmpd_double_figures(), SIGNED_VALUE, SSIZET2NUM, T_BIGNUM, T_DATA, T_FIXNUM, T_FLOAT, T_RATIONAL, ToValue(), TYPE, vabs, VP_SIGN_POSITIVE_INFINITE, VpCreateRbObject(), VpExponent10(), VpGetSign, VpIsNaN, VpIsNegInf, VpIsPosInf, VpIsZero, VpSetInf, VpSetNaN, and VpSetSign.

Referenced by Init_bigdecimal().

static VALUE BigMath_s_log | ( | VALUE | klass,
|  | VALUE | x,
|  | VALUE | vprec
| ) |  |
| static

Definition at line 2753 of file bigdecimal.c.

References argv, BigDecimal_add(), BigDecimal_div2(), BigDecimal_mult(), BigDecimal_mult2(), BigDecimal_sub(), buf, cannot_be_coerced_into_BigDecimal(), DATA_PTR, DBL_DIG, FIX2LONG, GetVpValue(), GetVpValueWithPrec(), i, INT2FIX, is_integer(), is_kind_of_BigDecimal(), isinf(), isnan, NULL, NUM2SSIZET, Real::obj, one(), PRIdVALUE, rb_eArgError, rb_eMathDomainError, RB_GC_GUARD, rb_raise(), RBIGNUM_NEGATIVE_P, RBIGNUM_ZERO_P, RFLOAT_VALUE, rmpd_double_figures(), RRATIONAL_NEGATIVE_P, RRATIONAL_ZERO_P, SIGNED_VALUE, snprintf, SSIZET2NUM, T_BIGNUM, T_COMPLEX, T_DATA, T_FIXNUM, T_FLOAT, T_RATIONAL, ToValue(), TYPE, vabs, VP_SIGN_POSITIVE_INFINITE, VpCreateRbObject(), VpExponent10(), VpGetSign, VpIsNaN, VpIsNegInf, VpIsPosInf, VpIsZero, VpSetInf, VpSetNaN, and zero().

Referenced by Init_bigdecimal().

static int bigzero_p | ( | VALUE | x) |  |
| inline static

Definition at line 85 of file bigdecimal.c.

References BDIGIT, i, RBIGNUM_DIGITS, and RBIGNUM_LEN.

static void cannot_be_coerced_into_BigDecimal | ( | VALUE | exc_class,
|  | VALUE | v
| ) |  |
| static

Definition at line 177 of file bigdecimal.c.

References rb_class_name(), rb_exc_new3(), rb_exc_raise(), rb_inspect(), rb_obj_class(), rb_special_const_p(), rb_str_cat2(), and rb_str_dup().

Referenced by BigMath_s_exp(), BigMath_s_log(), and GetVpValueWithPrec().

static unsigned short check_rounding_mode | ( | VALUE const | v) |  |
| static

Definition at line 397 of file bigdecimal.c.

References Check_Type, FIX2UINT, id, id_banker, id_ceil, id_ceiling, id_default, id_down, id_floor, id_half_down, id_half_even, id_half_up, id_truncate, id_up, rb_eArgError, rb_raise(), SYM2ID, T_FIXNUM, T_SYMBOL, TYPE, VP_ROUND_CEIL, VP_ROUND_DOWN, VP_ROUND_FLOOR, VP_ROUND_HALF_DOWN, VP_ROUND_HALF_EVEN, VP_ROUND_HALF_UP, VP_ROUND_UP, and VpIsRoundMode().

Referenced by BigDecimal_mode(), and BigDecimal_round().

static size_t GetAddSubPrec | ( | Real * | a,
|  | Real * | b
| ) |  |
| static

Definition at line 526 of file bigdecimal.c.

References Real::exponent, Real::Prec, SIGNED_VALUE, VP_EXCEPTION_INFINITY, VpException(), and VpIsDef.

Referenced by BigDecimal_add(), BigDecimal_DoDivmod(), and BigDecimal_sub().

static SIGNED_VALUE GetPositiveInt | ( | VALUE | v) |  |
| static

Definition at line 547 of file bigdecimal.c.

References Check_Type, FIX2INT, rb_eArgError, rb_raise(), SIGNED_VALUE, and T_FIXNUM.

Referenced by BigDecimal_add2(), BigDecimal_div2(), BigDecimal_mult2(), BigDecimal_new(), BigDecimal_sqrt(), BigDecimal_sub2(), and BigDecimal_to_s().

static Real* GetVpValue | ( | VALUE | v,
|  | int | must
| ) |  |
| static

Definition at line 272 of file bigdecimal.c.

References GetVpValueWithPrec().

Referenced by BigDecimal_abs(), BigDecimal_add(), BigDecimal_add2(), BigDecimal_ceil(), BigDecimal_coerce(), BigDecimal_div2(), BigDecimal_divide(), BigDecimal_divremain(), BigDecimal_DoDivmod(), BigDecimal_dump(), BigDecimal_exponent(), BigDecimal_fix(), BigDecimal_floor(), BigDecimal_frac(), BigDecimal_hash(), BigDecimal_inspect(), BigDecimal_IsFinite(), BigDecimal_IsInfinite(), BigDecimal_IsNaN(), BigDecimal_mult(), BigDecimal_mult2(), BigDecimal_neg(), BigDecimal_new(), BigDecimal_nonzero(), BigDecimal_power(), BigDecimal_prec(), BigDecimal_round(), BigDecimal_sign(), BigDecimal_split(), BigDecimal_sqrt(), BigDecimal_sub(), BigDecimal_sub2(), BigDecimal_to_f(), BigDecimal_to_i(), BigDecimal_to_r(), BigDecimal_to_s(), BigDecimal_truncate(), BigDecimal_zero(), BigDecimalCmp(), BigMath_s_exp(), and BigMath_s_log().

static Real* GetVpValueWithPrec | ( | VALUE | v,
|  | long | prec,
|  | int | must
| ) |  |
| static

Definition at line 195 of file bigdecimal.c.

References args, BigDecimal_div2(), cannot_be_coerced_into_BigDecimal(), DATA_PTR, DBL_DIG, FIX2LONG, id_to_r, is_kind_of_BigDecimal(), LONG2NUM, NULL, Qundef, rb_big2str(), rb_eArgError, rb_eTypeError, rb_funcall(), rb_obj_classname(), rb_raise(), RRATIONAL, RSTRING_PTR, SafeStringValue, strlen(), T_BIGNUM, T_DATA, T_FIXNUM, T_FLOAT, T_RATIONAL, T_STRING, ToValue(), TYPE, VpBaseFig, and VpCreateRbObject().

Referenced by BigDecimal_add(), BigDecimal_coerce(), BigDecimal_divide(), BigDecimal_divremain(), BigDecimal_DoDivmod(), BigDecimal_mult(), BigDecimal_new(), BigDecimal_power(), BigDecimal_sub(), BigDecimalCmp(), BigMath_s_exp(), BigMath_s_log(), and GetVpValue().

void Init_bigdecimal | ( | void | ) |  |

Definition at line 3011 of file bigdecimal.c.

References arg, BigDecimal_abs(), BigDecimal_add(), BigDecimal_add2(), BigDecimal_ceil(), BigDecimal_coerce(), BigDecimal_comp(), BigDecimal_div(), BigDecimal_div2(), BigDecimal_divmod(), BigDecimal_double_fig(), BigDecimal_dump(), BigDecimal_eq(), BigDecimal_exponent(), BigDecimal_fix(), BigDecimal_floor(), BigDecimal_frac(), BigDecimal_ge(), BigDecimal_global_new(), BigDecimal_gt(), BigDecimal_hash(), BigDecimal_initialize(), BigDecimal_initialize_copy(), BigDecimal_inspect(), BigDecimal_IsFinite(), BigDecimal_IsInfinite(), BigDecimal_IsNaN(), BigDecimal_le(), BigDecimal_limit(), BigDecimal_load(), BigDecimal_lt(), BigDecimal_mod(), BigDecimal_mode(), BigDecimal_mult(), BigDecimal_mult2(), BigDecimal_neg(), BigDecimal_nonzero(), BigDecimal_power(), BigDecimal_power_op(), BigDecimal_prec(), BigDecimal_remainder(), BigDecimal_round(), BigDecimal_s_allocate(), BigDecimal_save_exception_mode(), BigDecimal_save_limit(), BigDecimal_save_rounding_mode(), BigDecimal_sign(), BigDecimal_split(), BigDecimal_sqrt(), BigDecimal_sub(), BigDecimal_sub2(), BigDecimal_to_f(), BigDecimal_to_i(), BigDecimal_to_r(), BigDecimal_to_s(), BigDecimal_truncate(), BigDecimal_uplus(), BigDecimal_version(), BigDecimal_zero(), BigMath_s_exp(), BigMath_s_log(), id_banker, id_BigDecimal_exception_mode, id_BigDecimal_precision_limit, id_BigDecimal_rounding_mode, id_ceil, id_ceiling, id_default, id_down, id_eq, id_floor, id_half_down, id_half_even, id_half_up, id_to_r, id_truncate, id_up, INT2FIX, rb_cBigDecimal, rb_cNumeric, rb_define_alloc_func(), rb_define_class(), rb_define_const(), rb_define_global_function(), rb_define_method(), rb_define_module(), rb_define_singleton_method(), rb_intern_const, rb_mBigMath, rb_str_new2, SIGNED_VALUE, VP_EXCEPTION_ALL, VP_EXCEPTION_INFINITY, VP_EXCEPTION_NaN, VP_EXCEPTION_OVERFLOW, VP_EXCEPTION_UNDERFLOW, VP_EXCEPTION_ZERODIVIDE, VP_ROUND_CEIL, VP_ROUND_DOWN, VP_ROUND_FLOOR, VP_ROUND_HALF_DOWN, VP_ROUND_HALF_EVEN, VP_ROUND_HALF_UP, VP_ROUND_MODE, VP_ROUND_UP, VP_SIGN_NaN, VP_SIGN_NEGATIVE_FINITE, VP_SIGN_NEGATIVE_INFINITE, VP_SIGN_NEGATIVE_ZERO, VP_SIGN_POSITIVE_FINITE, VP_SIGN_POSITIVE_INFINITE, VP_SIGN_POSITIVE_ZERO, VpBaseVal, and VpInit().

static int is_even | ( | VALUE | x) |  |
| inline static

Definition at line 2086 of file bigdecimal.c.

References FIX2LONG, RBIGNUM_DIGITS, T_BIGNUM, T_FIXNUM, and TYPE.

Referenced by BigDecimal_power().

static int is_integer | ( | VALUE | x) |  |
| inline static

Definition at line 2015 of file bigdecimal.c.

References RB_TYPE_P, T_BIGNUM, and T_FIXNUM.

Referenced by BigDecimal_power(), and BigMath_s_log().

static int is_kind_of_BigDecimal | ( | VALUE const | v) |  |
| inline static

Definition at line 156 of file bigdecimal.c.

References rb_typeddata_is_kind_of().

Referenced by BigDecimal_new(), BigDecimal_power(), BigDecimalCmp(), BigMath_s_exp(), BigMath_s_log(), and GetVpValueWithPrec().

static int is_negative | ( | VALUE | x) |  |
| inline static

Definition at line 2021 of file bigdecimal.c.

References FIX2LONG, FIXNUM_P, INT2FIX, rb_funcall(), RB_TYPE_P, RBIGNUM_NEGATIVE_P, RFLOAT_VALUE, RTEST, T_BIGNUM, and T_FLOAT.

Referenced by BigDecimal_power().

static int is_one | ( | VALUE | x) |  |
| inline static

Definition at line 2061 of file bigdecimal.c.

References FIX2LONG, FIXNUM_P, id_eq, INT2FIX, Qfalse, rb_funcall(), RRATIONAL, RTEST, T_BIGNUM, T_FIXNUM, T_RATIONAL, and TYPE.

Referenced by BigDecimal_power().

static int is_zero | ( | VALUE | x) |  |
| inline static

Definition at line 2038 of file bigdecimal.c.

References FIX2LONG, FIXNUM_P, id_eq, INT2FIX, Qfalse, rb_funcall(), RRATIONAL, RTEST, T_BIGNUM, T_FIXNUM, T_RATIONAL, and TYPE.

Referenced by BigDecimal_power().

NORETURN | ( | static void | cannot_be_coerced_into_BigDecimalVALUE, VALUE) |  |

static double One | ( | void | ) |  |
| static

Definition at line 3453 of file bigdecimal.c.

References gOne_ABCED9B4_CE73__00400511F31D.

Referenced by VpGetDoubleNegInf(), VpGetDoubleNegZero(), and VpGetDoublePosInf().

static VALUE rmpd_power_by_big_decimal | ( | Real const * | x,
|  | Real const * | exp,
|  | ssize_t const | n
| ) |  |
| static

Definition at line 2103 of file bigdecimal.c.

References BigDecimal_mult2(), BigMath_exp, BigMath_log, Real::obj, RB_GC_GUARD, SSIZET2NUM, ToValue(), VpCreateRbObject(), and VpIsZero.

Referenced by BigDecimal_power().

static VALUE ToValue | ( | Real * | p) |  |
| static

Definition at line 162 of file bigdecimal.c.

References Real::obj, VP_EXCEPTION_INFINITY, VP_EXCEPTION_NaN, VpException(), VpIsNaN, VpIsNegInf, and VpIsPosInf.

Referenced by BigDecimal_abs(), BigDecimal_add(), BigDecimal_add2(), BigDecimal_ceil(), BigDecimal_div(), BigDecimal_div2(), BigDecimal_divmod(), BigDecimal_fix(), BigDecimal_floor(), BigDecimal_frac(), BigDecimal_global_new(), BigDecimal_initialize(), BigDecimal_load(), BigDecimal_mod(), BigDecimal_mult(), BigDecimal_mult2(), BigDecimal_neg(), BigDecimal_power(), BigDecimal_remainder(), BigDecimal_round(), BigDecimal_sqrt(), BigDecimal_sub(), BigDecimal_sub2(), BigDecimal_truncate(), BigMath_s_exp(), BigMath_s_log(), GetVpValueWithPrec(), and rmpd_power_by_big_decimal().

VP_EXPORT int VpActiveRound | ( | Real * | y,
|  | Real * | x,
|  | unsigned short | f,
|  | ssize_t | nf
| ) |  |

Definition at line 5819 of file bigdecimal.c.

References VpAsgn(), and VpMidRound().

Referenced by BigDecimal_ceil(), BigDecimal_divremain(), BigDecimal_DoDivmod(), BigDecimal_fix(), BigDecimal_floor(), BigDecimal_round(), and BigDecimal_truncate().

static BDIGIT VpAddAbs | ( | Real * | a,
|  | Real * | b,
|  | Real * | c
| ) |  |
| static

Definition at line 4099 of file bigdecimal.c.

References BASE, BDIGIT, bp, Real::frac, VpAsgn(), and VpSetPTR().

Referenced by VpAddSub().

VP_EXPORT size_t VpAddSub | ( | Real * | c,
|  | Real * | a,
|  | Real * | b,
|  | int | operation
| ) |  |

Definition at line 3971 of file bigdecimal.c.

References BASE_FIG, BDIGIT, Real::exponent, Real::frac, i, Min, Real::Prec, VpAddAbs(), VpAsgn(), VpGetSign, VpInternalRound(), VpIsDefOP(), VpIsZero, VpSetSign, VpSetZero, and VpSubAbs().

Referenced by BigDecimal_add(), BigDecimal_divremain(), BigDecimal_DoDivmod(), BigDecimal_sub(), and VpSqrt().

VP_EXPORT Real* VpAlloc | ( | size_t | mx,
|  | const char * | szVal
| ) |  |

Definition at line 3776 of file bigdecimal.c.

References BASE_FIG, buf, i, ISDIGIT, ISSPACE, Max, Real::MaxPrec, ne, NULL, rb_str_resize(), rb_str_tmp_new(), RSTRING_PTR, StrCmp, strlen(), SZ_INF, SZ_NaN, SZ_NINF, SZ_PINF, v, VpAllocReal, VpCtoV(), VpGetPrecLimit(), VpSetNaN, VpSetNegInf, VpSetPosInf, and VpSetZero.

Referenced by BigDecimal_new(), VpCreateRbObject(), VpInit(), VpMult(), VpNewRbClass(), VpPower(), and VpSqrt().

VP_EXPORT size_t VpAsgn | ( | Real * | c,
|  | Real * | a,
|  | int | isw
| ) |  |

Definition at line 3929 of file bigdecimal.c.

References BASE_FIG, BDIGIT, Real::exponent, Real::frac, Real::MaxPrec, Real::Prec, VpGetSign, VpInternalRound(), VpIsInf, VpIsNaN, VpIsZero, VpLimitRound(), VpSetInf, VpSetNaN, VpSetSign, and VpSetZero.

Referenced by BigDecimal_abs(), BigDecimal_neg(), VpActiveRound(), VpAddAbs(), VpAddSub(), VpDivd(), VpFrac(), VpMult(), VpPower(), VpSqrt(), and VpSubAbs().

VP_EXPORT int VpComp | ( | Real * | a,
|  | Real * | b
| ) |  |

Definition at line 4771 of file bigdecimal.c.

References Real::exponent, Real::frac, Real::Prec, Real::sign, val, VpGetSign, VpIsDef, VpIsNaN, and VpIsZero.

Referenced by BigDecimalCmp().

static Real * VpCopy | ( | Real * | pv,
|  | Real const *const | x
| ) |  |
| static

Definition at line 578 of file bigdecimal.c.

References assert, BDIGIT, Real::exponent, Real::flag, Real::frac, Real::MaxPrec, MEMCPY, NULL, Real::Prec, Real::sign, and VpReallocReal.

Referenced by BigDecimal_global_new(), BigDecimal_initialize(), and BigDecimal_initialize_copy().

VP_EXPORT Real* VpCreateRbObject | ( | size_t | mx,
|  | const char * | str
| ) |  |

Definition at line 567 of file bigdecimal.c.

References Real::obj, rb_cBigDecimal, TypedData_Wrap_Struct, and VpAlloc().

Referenced by BigDecimal_abs(), BigDecimal_add(), BigDecimal_ceil(), BigDecimal_div2(), BigDecimal_divide(), BigDecimal_divremain(), BigDecimal_DoDivmod(), BigDecimal_fix(), BigDecimal_floor(), BigDecimal_frac(), BigDecimal_mult(), BigDecimal_neg(), BigDecimal_power(), BigDecimal_round(), BigDecimal_sqrt(), BigDecimal_sub(), BigDecimal_truncate(), BigMath_s_exp(), BigMath_s_log(), GetVpValueWithPrec(), and rmpd_power_by_big_decimal().

VP_EXPORT int VpCtoV | ( | Real * | a,
|  | const char * | int_chr,
|  | size_t | ni,
|  | const char * | frac,
|  | size_t | nf,
|  | const char * | exp_chr,
|  | size_t | ne
| ) |  |

Definition at line 5192 of file bigdecimal.c.

References BASE_FIG, BDIGIT, Real::exponent, Real::frac, i, Real::MaxPrec, ne, Real::Prec, rb_warn(), SIGNED_VALUE, VP_EXCEPTION_INFINITY, VpException(), VpNmlz(), VpSetInf, VpSetSign, VpSetZero, and zero().

Referenced by VpAlloc().

VP_EXPORT size_t VpDivd | ( | Real * | c,
|  | Real * | r,
|  | Real * | a,
|  | Real * | b
| ) |  |

Definition at line 4522 of file bigdecimal.c.

References AddExponent(), BASE, BASE_FIG, BDIGIT, BDIGIT_DBL, Real::exponent, Real::frac, i, Real::MaxPrec, Min, Real::Prec, rb_bug(), VP_EXCEPTION_NaN, VP_EXCEPTION_ZERODIVIDE, VpAsgn(), VpException(), VpGetSign, VpIsDefOP(), VpIsOne, VpIsZero, VpNmlz(), VpSetInf, VpSetNaN, VpSetSign, and VpSetZero.

Referenced by BigDecimal_div2(), BigDecimal_divide(), BigDecimal_divremain(), BigDecimal_DoDivmod(), VpPower(), and VpSqrt().

VP_EXPORT void VpDtoV | ( | Real * | m,
|  | double | d
| ) |  |

Definition at line 5405 of file bigdecimal.c.

References BASE, BDIGIT, Real::exponent, Real::frac, i, isinf(), isnan, Real::MaxPrec, ne, Real::Prec, SIGNED_VALUE, val, VpInternalRound(), VpSetNaN, VpSetNegInf, VpSetPosInf, VpSetSign, and VpSetZero.

Referenced by VpSqrt().

VP_EXPORT int VpException | ( | unsigned short | f,
|  | const char * | str,
|  | int | always
| ) |  |

Definition at line 3514 of file bigdecimal.c.

References rb_eFloatDomainError, rb_fatal(), rb_raise(), VP_EXCEPTION_INFINITY, VP_EXCEPTION_MEMORY, VP_EXCEPTION_NaN, VP_EXCEPTION_OP, VP_EXCEPTION_UNDERFLOW, VP_EXCEPTION_ZERODIVIDE, and VpGetException().

Referenced by AddExponent(), BigDecimal_check_num(), BigDecimal_to_f(), GetAddSubPrec(), ToValue(), VpCtoV(), VpDivd(), VpIsDefOP(), VpMemAlloc(), VpMemRealloc(), and VpSqrt().

VP_EXPORT ssize_t VpExponent10 | ( | Real * | a) |  |

Definition at line 4985 of file bigdecimal.c.

References BASE1, BASE_FIG, Real::exponent, Real::frac, and VpHasVal.

Referenced by BigDecimal_exponent(), BigDecimal_split(), BigDecimal_to_i(), BigDecimal_to_r(), BigMath_s_exp(), and BigMath_s_log().

static void VpFormatSt | ( | char * | psz,
|  | size_t | fFmt
| ) |  |
| static

Definition at line 4960 of file bigdecimal.c.

References i, ISSPACE, memmove(), and strlen().

Referenced by VpToFString(), and VpToString().

VP_EXPORT void VpFrac | ( | Real * | y,
|  | Real * | x
| ) |  |

Definition at line 5913 of file bigdecimal.c.

References Real::exponent, Real::frac, Real::MaxPrec, Min, Real::Prec, VpAsgn(), VpGetSign, VpHasVal, VpNmlz(), VpSetSign, and VpSetZero.

Referenced by BigDecimal_divremain(), and BigDecimal_frac().

VP_EXPORT void VpFree | ( | Real * | pv) |  |

Definition at line 3292 of file bigdecimal.c.

References getchar, NULL, and xfree.

Referenced by BigDecimal_delete(), BigDecimal_initialize(), VpMult(), VpPower(), and VpSqrt().

VP_EXPORT double VpGetDoubleNaN | ( | void | ) |  |

Definition at line 3473 of file bigdecimal.c.

References Zero().

Referenced by VpInit(), and VpVtoD().

VP_EXPORT double VpGetDoubleNegInf | ( | void | ) |  |

Definition at line 3489 of file bigdecimal.c.

References One(), and Zero().

Referenced by BigDecimal_to_f(), VpGetDoubleNegZero(), VpInit(), and VpVtoD().

VP_EXPORT double VpGetDoubleNegZero | ( | void | ) |  |

Definition at line 3497 of file bigdecimal.c.

References One(), and VpGetDoubleNegInf().

Referenced by VpInit(), and VpVtoD().

VP_EXPORT double VpGetDoublePosInf | ( | void | ) |  |

Definition at line 3481 of file bigdecimal.c.

References One(), and Zero().

Referenced by BigDecimal_to_f(), VpInit(), and VpVtoD().

static unsigned short VpGetException | ( | void | ) |  |
| static

Definition at line 3322 of file bigdecimal.c.

References FIX2UINT, id_BigDecimal_exception_mode, NIL_P, rb_thread_current(), rb_thread_local_aref(), RMPD_EXCEPTION_MODE_DEFAULT, and rmpd_set_thread_local_exception_mode.

Referenced by BigDecimal_mode(), BigDecimal_save_exception_mode(), and VpException().

VP_EXPORT size_t VpGetPrecLimit | ( | void | ) |  |

Definition at line 3357 of file bigdecimal.c.

References id_BigDecimal_precision_limit, NIL_P, NUM2SIZET, rb_thread_current(), rb_thread_local_aref(), RMPD_PRECISION_LIMIT_DEFAULT, and rmpd_set_thread_local_precision_limit.

Referenced by BigDecimal_limit(), BigDecimal_save_limit(), VpAlloc(), VpLimitRound(), and VpSetPrecLimit().

VP_EXPORT unsigned short VpGetRoundMode | ( | void | ) |  |

Definition at line 3392 of file bigdecimal.c.

References FIX2INT, id_BigDecimal_rounding_mode, NIL_P, rb_thread_current(), rb_thread_local_aref(), RMPD_ROUNDING_MODE_DEFAULT, and rmpd_set_thread_local_rounding_mode.

Referenced by BigDecimal_add2(), BigDecimal_div2(), BigDecimal_mode(), BigDecimal_mult2(), BigDecimal_round(), BigDecimal_save_rounding_mode(), BigDecimal_sub2(), VpInternalRound(), VpLimitRound(), and VpSetRoundMode().

VP_EXPORT size_t VpInit | ( | BDIGIT | BaseVal) |  |

Definition at line 3695 of file bigdecimal.c.

References BASE, BASE1, BASE_FIG, DBLE_FIG, HALF_BASE, rmpd_double_figures(), VpAlloc(), VpGetDoubleNaN(), VpGetDoubleNegInf(), VpGetDoubleNegZero(), and VpGetDoublePosInf().

Referenced by Init_bigdecimal().

static void VpInternalRound | ( | Real * | c,
|  | size_t | ixDigit,
|  | BDIGIT | vPrev,
|  | BDIGIT | v
| ) |  |
| static

Definition at line 5840 of file bigdecimal.c.

References BASE1, f, VP_ROUND_CEIL, VP_ROUND_DOWN, VP_ROUND_FLOOR, VP_ROUND_HALF_DOWN, VP_ROUND_HALF_EVEN, VP_ROUND_HALF_UP, VP_ROUND_UP, VpGetRoundMode(), VpGetSign, VpLimitRound(), VpNmlz(), and VpRdup().

Referenced by BigDecimal_div(), VpAddSub(), VpAsgn(), and VpDtoV().

static int VpIsDefOP | ( | Real * | c,
|  | Real * | a,
|  | Real * | b,
|  | int | sw
| ) |  |
| static

Definition at line 3554 of file bigdecimal.c.

References VP_EXCEPTION_INFINITY, VP_EXCEPTION_NaN, VpException(), VpGetSign, VpIsInf, VpIsNaN, VpIsZero, VpSetInf, VpSetNaN, and VpSetZero.

Referenced by VpAddSub(), VpDivd(), and VpMult().

VP_EXPORT int VpIsRoundMode | ( | unsigned short | n) |  |

Definition at line 3408 of file bigdecimal.c.

References VP_ROUND_CEIL, VP_ROUND_DOWN, VP_ROUND_FLOOR, VP_ROUND_HALF_DOWN, VP_ROUND_HALF_EVEN, VP_ROUND_HALF_UP, and VP_ROUND_UP.

Referenced by check_rounding_mode(), and VpSetRoundMode().

VP_EXPORT int VpLeftRound | ( | Real * | y,
|  | unsigned short | f,
|  | ssize_t | nf
| ) |  |

Definition at line 5804 of file bigdecimal.c.

References BASE_FIG, BDIGIT, Real::frac, v, VpExponent, VpHasVal, and VpMidRound().

Referenced by BigDecimal_add2(), BigDecimal_div2(), BigDecimal_mult2(), BigDecimal_sub2(), and VpLimitRound().

static int VpLimitRound | ( | Real * | c,
|  | size_t | ixDigit
| ) |  |
| static

Definition at line 5827 of file bigdecimal.c.

References BASE_FIG, Real::Prec, VpGetPrecLimit(), VpGetRoundMode(), VpLeftRound(), and VpNmlz().

Referenced by VpAsgn(), VpInternalRound(), and VpMult().

VP_EXPORT void* VpMemAlloc | ( | size_t | mb) |  |

Definition at line 3268 of file bigdecimal.c.

References p, VP_EXCEPTION_MEMORY, VpException(), and xmalloc.

VP_EXPORT void* VpMemRealloc | ( | void * | ptr,
|  | size_t | mb
| ) |  |

Definition at line 3282 of file bigdecimal.c.

References p, VP_EXCEPTION_MEMORY, VpException(), and xrealloc.

VP_EXPORT int VpMidRound | ( | Real * | y,
|  | unsigned short | f,
|  | ssize_t | nf
| ) |  |

Definition at line 5644 of file bigdecimal.c.

References BASE, BASE_FIG, BDIGIT, div, Real::exponent, Real::frac, i, Real::Prec, SIGNED_VALUE, v, VP_ROUND_CEIL, VP_ROUND_DOWN, VP_ROUND_FLOOR, VP_ROUND_HALF_DOWN, VP_ROUND_HALF_EVEN, VP_ROUND_HALF_UP, VP_ROUND_UP, VpGetSign, VpNmlz(), VpRdup(), VpSetOne, VpSetSign, and VpSetZero.

Referenced by VpActiveRound(), and VpLeftRound().

VP_EXPORT size_t VpMult | ( | Real * | c,
|  | Real * | a,
|  | Real * | b
| ) |  |

Definition at line 4397 of file bigdecimal.c.

References AddExponent(), BASE, BASE_FIG, BDIGIT, BDIGIT_DBL, c, Real::exponent, Real::frac, i, Real::MaxPrec, NULL, Real::Prec, VpAlloc(), VpAsgn(), VpFree(), VpGetSign, VpIsDefOP(), VpIsOne, VpIsZero, VpLimitRound(), VpNmlz(), VpSetSign, and VpSetZero.

Referenced by BigDecimal_divremain(), BigDecimal_DoDivmod(), BigDecimal_mult(), VpPower(), and VpSqrt().

VP_EXPORT Real* VpNewRbClass | ( | size_t | mx,
|  | const char * | str,
|  | VALUE | klass
| ) |  |

Definition at line 559 of file bigdecimal.c.

References Real::obj, TypedData_Wrap_Struct, and VpAlloc().

Referenced by BigDecimal_load(), and BigDecimal_s_allocate().

static int VpNmlz | ( | Real * | a) |  |
| static

Definition at line 4733 of file bigdecimal.c.

References AddExponent(), BDIGIT, Real::frac, i, memmove(), Real::Prec, SIGNED_VALUE, VpGetSign, VpIsDef, VpIsZero, and VpSetZero.

Referenced by VpCtoV(), VpDivd(), VpFrac(), VpInternalRound(), VpLimitRound(), VpMidRound(), VpMult(), and VpRdup().

VP_EXPORT size_t VpNumOfChars | ( | Real * | vp,
|  | const char * | pszFmt
| ) |  |

Definition at line 3651 of file bigdecimal.c.

References BASE_FIG, Real::exponent, NULL, Real::Prec, SIGNED_VALUE, and VpIsDef.

Referenced by BigDecimal_dump(), BigDecimal_inspect(), BigDecimal_split(), BigDecimal_to_f(), and BigDecimal_to_s().

VP_EXPORT Real* VpOne | ( | void | ) |  |

Definition at line 3726 of file bigdecimal.c.

References VpConstOne.

Referenced by BigDecimal_DoDivmod().

VP_EXPORT int VpPower | ( | Real * | y,
|  | Real * | x,
|  | SIGNED_VALUE | n
| ) |  |

Definition at line 5961 of file bigdecimal.c.

References BASE_FIG, Real::exponent, Real::frac, Real::MaxPrec, NULL, Real::Prec, SIGNED_VALUE, VpAlloc(), VpAsgn(), VpDivd(), VpFree(), VpGetSign, VpIsInf, VpIsNaN, VpIsPosInf, VpIsZero, VpMult(), VpSetInf, VpSetNaN, VpSetOne, VpSetSign, and VpSetZero.

Referenced by BigDecimal_power().

static int VpRdup | ( | Real * | m,
|  | size_t | ind_m
| ) |  |
| static

Definition at line 5888 of file bigdecimal.c.

References AddExponent(), BASE, BDIGIT, Real::frac, Real::Prec, and VpNmlz().

Referenced by VpInternalRound(), and VpMidRound().

static void VpSetException | ( | unsigned short | f) |  |
| static

Definition at line 3338 of file bigdecimal.c.

References rmpd_set_thread_local_exception_mode.

Referenced by BigDecimal_mode(), and BigDecimal_save_exception_mode().

VP_EXPORT size_t VpSetPrecLimit | ( | size_t | n) |  |

Definition at line 3373 of file bigdecimal.c.

References rmpd_set_thread_local_precision_limit, and VpGetPrecLimit().

Referenced by BigDecimal_add2(), BigDecimal_ceil(), BigDecimal_div2(), BigDecimal_floor(), BigDecimal_limit(), BigDecimal_mult2(), BigDecimal_round(), BigDecimal_save_limit(), BigDecimal_sub2(), and BigDecimal_truncate().

static size_t VpSetPTR | ( | Real * | a,
|  | Real * | b,
|  | Real * | c,
|  | size_t * | a_pos,
|  | size_t * | b_pos,
|  | size_t * | c_pos,
|  | BDIGIT * | av,
|  | BDIGIT * | bv
| ) |  |
| static

Definition at line 4302 of file bigdecimal.c.

References AddExponent(), Real::exponent, Real::frac, Max, Real::MaxPrec, and Real::Prec.

Referenced by VpAddAbs(), and VpSubAbs().

VP_EXPORT unsigned short VpSetRoundMode | ( | unsigned short | n) |  |

Definition at line 3426 of file bigdecimal.c.

References rmpd_set_thread_local_rounding_mode, VpGetRoundMode(), and VpIsRoundMode().

Referenced by BigDecimal_mode(), and BigDecimal_save_rounding_mode().

VP_EXPORT int VpSqrt | ( | Real * | y,
|  | Real * | x
| ) |  |

Definition at line 5535 of file bigdecimal.c.

References BASE, BASE_FIG, DBLE_FIG, Real::exponent, f, if(), maxnr, Real::MaxPrec, Min, NULL, PRIdSIZE, SIGNED_VALUE, VP_EXCEPTION_OP, VpAddSub(), VpAlloc(), VpAsgn(), VpChangeSign, VpDivd(), VpDtoV(), VpException(), VpFree(), VpGetSign, VpHasVal, VpIsOne, VpIsZero, VpMult(), VpSetNaN, VpSetOne, and VpVtoD().

Referenced by BigDecimal_sqrt().

static BDIGIT VpSubAbs | ( | Real * | a,
|  | Real * | b,
|  | Real * | c
| ) |  |
| static

Definition at line 4190 of file bigdecimal.c.

References BASE, BDIGIT, bp, Real::frac, VpAsgn(), and VpSetPTR().

Referenced by VpAddSub().

VP_EXPORT void VpSzMantissa | ( | Real * | a,
|  | char * | psz
| ) |  |

Definition at line 5002 of file bigdecimal.c.

References BASE1, BDIGIT_DBL, Real::frac, i, Real::Prec, strlen(), SZ_INF, SZ_NaN, SZ_NINF, VpGetSign, VpIsNaN, VpIsNegInf, VpIsPosInf, VpIsPosZero, and VpIsZero.

Referenced by BigDecimal_split().

VP_EXPORT void VpToFString | ( | Real * | a,
|  | char * | psz,
|  | size_t | fFmt,
|  | int | fPlus
| ) |  |

Definition at line 5127 of file bigdecimal.c.

References BASE, BASE1, BASE_FIG, BDIGIT, Real::exponent, Real::frac, i, Real::Prec, strlen(), VpFormatSt(), VpGetSign, and VpToSpecialString().

Referenced by BigDecimal_to_s().

VP_EXPORT int VpToSpecialString | ( | Real * | a,
|  | char * | psz,
|  | int | fPlus
| ) |  |

Definition at line 5048 of file bigdecimal.c.

References SZ_INF, SZ_NaN, SZ_NINF, VpIsNaN, VpIsNegInf, VpIsPosInf, VpIsPosZero, and VpIsZero.

Referenced by VpToFString(), and VpToString().

VP_EXPORT void VpToString | ( | Real * | a,
|  | char * | psz,
|  | size_t | fFmt,
|  | int | fPlus
| ) |  |

Definition at line 5081 of file bigdecimal.c.

References BASE1, BASE_FIG, BDIGIT, Real::exponent, Real::frac, i, Real::Prec, PRIdSIZE, shift(), strlen(), VpFormatSt(), VpGetSign, and VpToSpecialString().

Referenced by BigDecimal_dump(), BigDecimal_inspect(), BigDecimal_to_f(), and BigDecimal_to_s().

VP_EXPORT int VpVtoD | ( | double * | d,
|  | SIGNED_VALUE * | e,
|  | Real * | m
| ) |  |

Definition at line 5341 of file bigdecimal.c.

References BASE, BASE_FIG, DBLE_FIG, div, Real::exponent, f, Real::frac, Min, Real::Prec, SIGNED_VALUE, VpGetDoubleNaN(), VpGetDoubleNegInf(), VpGetDoubleNegZero(), VpGetDoublePosInf(), VpGetSign, VpIsNaN, VpIsNegInf, VpIsNegZero, VpIsPosInf, and VpIsPosZero.

Referenced by BigDecimal_to_f(), and VpSqrt().

static double Zero | ( | void | ) |  |
| static

Definition at line 3447 of file bigdecimal.c.

References gZero_ABCED9B1_CE73__00400511F31D.

Referenced by VpGetDoubleNaN(), VpGetDoubleNegInf(), and VpGetDoublePosInf().

## Variable Documentation

const rb_data_type_t BigDecimal_data_type
| static

Initial value:
= {
"BigDecimal",
{0, BigDecimal_delete, BigDecimal_memsize,},
}

Definition at line 150 of file bigdecimal.c.

volatile const double gOne_ABCED9B4_CE73__00400511F31D = 1.0

Definition at line 3445 of file bigdecimal.c.

Referenced by One().

volatile const double gZero_ABCED9B1_CE73__00400511F31D = 0.0

Definition at line 3444 of file bigdecimal.c.

Referenced by Zero().

ID id_banker
| static

Definition at line 55 of file bigdecimal.c.

Referenced by check_rounding_mode(), and Init_bigdecimal().

ID id_BigDecimal_exception_mode
| static

Definition at line 44 of file bigdecimal.c.

Referenced by Init_bigdecimal(), and VpGetException().

ID id_BigDecimal_precision_limit
| static

Definition at line 46 of file bigdecimal.c.

Referenced by Init_bigdecimal(), and VpGetPrecLimit().

ID id_BigDecimal_rounding_mode
| static

Definition at line 45 of file bigdecimal.c.

Referenced by Init_bigdecimal(), and VpGetRoundMode().

ID id_ceil
| static

Definition at line 57 of file bigdecimal.c.

Referenced by check_rounding_mode(), and Init_bigdecimal().

ID id_ceiling
| static

Definition at line 56 of file bigdecimal.c.

Referenced by check_rounding_mode(), and Init_bigdecimal().

ID id_default
| static

Definition at line 52 of file bigdecimal.c.

Referenced by check_rounding_mode(), and Init_bigdecimal().

ID id_down
| static

Definition at line 49 of file bigdecimal.c.

Referenced by check_rounding_mode(), and Init_bigdecimal().

ID id_eq
| static

Definition at line 60 of file bigdecimal.c.

Referenced by Init_bigdecimal(), is_one(), and is_zero().

ID id_floor
| static

Definition at line 58 of file bigdecimal.c.

Referenced by check_rounding_mode(), and Init_bigdecimal().

ID id_half_down
| static

Definition at line 53 of file bigdecimal.c.

Referenced by check_rounding_mode(), and Init_bigdecimal().

ID id_half_even
| static

Definition at line 54 of file bigdecimal.c.

Referenced by check_rounding_mode(), and Init_bigdecimal().

ID id_half_up
| static

Definition at line 51 of file bigdecimal.c.

Referenced by check_rounding_mode(), and Init_bigdecimal().

ID id_to_r
| static

Definition at line 59 of file bigdecimal.c.

Referenced by GetVpValueWithPrec(), and Init_bigdecimal().

ID id_truncate
| static

Definition at line 50 of file bigdecimal.c.

Referenced by check_rounding_mode(), and Init_bigdecimal().

ID id_up
| static

Definition at line 48 of file bigdecimal.c.

Referenced by check_rounding_mode(), and Init_bigdecimal().

VALUE rb_cBigDecimal

Definition at line 41 of file bigdecimal.c.

Referenced by BigDecimal_global_new(), Init_bigdecimal(), and VpCreateRbObject().

VALUE rb_mBigMath

Definition at line 42 of file bigdecimal.c.

Referenced by Init_bigdecimal().

Real* VpConstOne
| static

Definition at line 3245 of file bigdecimal.c.

Referenced by VpOne().

Real* VpPt5
| static

Definition at line 3246 of file bigdecimal.c.