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>`

Go to the source code of this file.

## Macros

#define | NDEBUG
#define | ENTER(n) volatile VALUE vStack[n];int iStack=0
#define | PUSH(x) vStack[iStack++] = (unsigned long)(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 | 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 * | VpDup (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_new (int argc, VALUE *argv, VALUE self)
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 | 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 1887 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 1888 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 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_new(), 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_new(), 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 1911 of file bigdecimal.c.

Referenced by BigDecimal_power().

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

Definition at line 3033 of file bigdecimal.c.

Referenced by VpSqrt().

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

Definition at line 3037 of file bigdecimal.c.

#define NDEBUG

Definition at line 23 of file bigdecimal.c.

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

Definition at line 64 of file bigdecimal.c.

#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 3129 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 3090 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 3123 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 3160 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 3038 of file bigdecimal.c.

Referenced by VpAlloc().

## Function Documentation

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

static

Definition at line 3509 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 1424 of file bigdecimal.c.

References 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 806 of file bigdecimal.c.

References DoSomeOne, ENTER, GetAddSubPrec(), GetVpValue(), GUARD_OBJ, Real::obj, SAVE, 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 1367 of file bigdecimal.c.

References BigDecimal_add(), 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 1670 of file bigdecimal.c.

References BigDecimal_to_i(), 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 611 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 765 of file bigdecimal.c.

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

Referenced by Init_bigdecimal().

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

static

Definition at line 985 of file bigdecimal.c.

References BigDecimalCmp().

Referenced by Init_bigdecimal().

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

static

Definition at line 141 of file bigdecimal.c.

References VpFree().

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

static

Definition at line 1134 of file bigdecimal.c.

References BDIGIT, BDIGIT_DBL, BigDecimal_divide(), 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 1331 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 1095 of file bigdecimal.c.

References DoSomeOne, ENTER, Real::exponent, GetVpValue(), GUARD_OBJ, Real::Prec, SAVE, vabs, VpBaseFig, VpCreateRbObject(), and VpDivd().

Referenced by BigDecimal_div().

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

static

Definition at line 1318 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 1248 of file bigdecimal.c.

References DoSomeOne, ENTER, GetVpValue(), GUARD_OBJ, Real::MaxPrec, NULL, rb_intern, SAVE, 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 1158 of file bigdecimal.c.

References ENTER, Real::exponent, GetAddSubPrec(), GetVpValue(), GUARD_OBJ, NULL, Real::Prec, Qfalse, Qtrue, rb_eZeroDivError, rb_raise(), SAVE, SIGNED_VALUE, 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 289 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 334 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 1001 of file bigdecimal.c.

References BigDecimalCmp().

Referenced by BigDecimal_power(), and Init_bigdecimal().

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

static

Definition at line 1844 of file bigdecimal.c.

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

Referenced by Init_bigdecimal().

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

static

Definition at line 1465 of file bigdecimal.c.

References 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 1621 of file bigdecimal.c.

References BigDecimal_to_i(), 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 1588 of file bigdecimal.c.

References 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 1049 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 2303 of file bigdecimal.c.

References BigDecimal_new(), and rb_cBigDecimal.

Referenced by Init_bigdecimal().

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

static

Definition at line 1037 of file bigdecimal.c.

References BigDecimalCmp().

Referenced by Init_bigdecimal().

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

static

Definition at line 317 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_inspect | ( | VALUE | self | ) |

static

Definition at line 1861 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 602 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 592 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 581 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 1025 of file bigdecimal.c.

References BigDecimalCmp().

Referenced by Init_bigdecimal().

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

static

Definition at line 2321 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 356 of file bigdecimal.c.

References ENTER, GUARD_OBJ, ISDIGIT, long, 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 1013 of file bigdecimal.c.

References BigDecimalCmp().

Referenced by Init_bigdecimal().

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

static

Definition at line 147 of file bigdecimal.c.

References BDIGIT, and Real::MaxPrec.

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

static

Definition at line 1235 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 455 of file bigdecimal.c.

References check_rounding_mode(), Check_Type, FIX2INT, INT2FIX, long, NIL_P, Qfalse, Qnil, Qtrue, rb_eArgError, rb_eTypeError, rb_raise(), rb_scan_args(), T_FIXNUM, 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 1077 of file bigdecimal.c.

References DoSomeOne, ENTER, GetVpValue(), GUARD_OBJ, Real::Prec, SAVE, 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 1401 of file bigdecimal.c.

References BigDecimal_mult(), 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 1055 of file bigdecimal.c.

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

Referenced by Init_bigdecimal().

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

static

Definition at line 2252 of file bigdecimal.c.

References DATA_PTR, DBL_DIG, ENTER, GetPositiveInt(), GetVpValue(), GetVpValueWithPrec(), GUARD_OBJ, is_kind_of_BigDecimal(), NIL_P, rb_eArgError, rb_raise(), rb_scan_args(), RSTRING_PTR, SafeStringValue, T_BIGNUM, T_DATA, T_FIXNUM, T_FLOAT, T_RATIONAL, T_STRING, ToValue(), TYPE, VpDup(), and VpNewRbClass().

Referenced by BigDecimal_global_new(), and Init_bigdecimal().

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

static

Definition at line 975 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 2003 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(), 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 2229 of file bigdecimal.c.

References BigDecimal_power().

Referenced by Init_bigdecimal().

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

static

Definition at line 304 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 1289 of file bigdecimal.c.

References BigDecimal_divremain(), and ToValue().

Referenced by Init_bigdecimal().

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

static

Definition at line 1501 of file bigdecimal.c.

References BigDecimal_to_i(), 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_save_exception_mode | ( | VALUE | self | ) |

static

Definition at line 2366 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 2394 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 2380 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 2356 of file bigdecimal.c.

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

Referenced by Init_bigdecimal().

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

static

Definition at line 1807 of file bigdecimal.c.

References ENTER, GetVpValue(), GUARD_OBJ, INT2FIX, INT2NUM(), len, 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 1446 of file bigdecimal.c.

References 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 844 of file bigdecimal.c.

References DoSomeOne, ENTER, GetAddSubPrec(), GetVpValue(), GUARD_OBJ, Real::obj, SAVE, 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 1384 of file bigdecimal.c.

References BigDecimal_sub(), 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 674 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, 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 629 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(), RSTRING_LEN, T_FLOAT, TYPE, 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 719 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 1727 of file bigdecimal.c.

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

Referenced by Init_bigdecimal().

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

static

Definition at line 1559 of file bigdecimal.c.

References BigDecimal_to_i(), 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 789 of file bigdecimal.c.

Referenced by Init_bigdecimal().

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

static

Definition at line 117 of file bigdecimal.c.

References rb_str_new2().

Referenced by Init_bigdecimal().

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

static

Definition at line 967 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 874 of file bigdecimal.c.

References DBL_DIG, ENTER, 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, 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 2415 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 2547 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_kind_of_BigDecimal(), isinf(), isnan, NULL, NUM2SSIZET, Real::obj, one(), 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 180 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 381 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 510 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 531 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 276 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 199 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_coerce(), BigDecimal_new(), BigDecimal_power(), BigDecimalCmp(), BigMath_s_exp(), BigMath_s_log(), and GetVpValue().

void Init_bigdecimal | ( | void |  | ) |

Definition at line 2801 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_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_new(), BigDecimal_nonzero(), BigDecimal_power(), BigDecimal_power_op(), BigDecimal_prec(), BigDecimal_remainder(), BigDecimal_round(), 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_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 1962 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 1891 of file bigdecimal.c.

References T_BIGNUM, T_FIXNUM, and TYPE.

Referenced by BigDecimal_power().

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

inline static

Definition at line 159 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 1897 of file bigdecimal.c.

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

Referenced by BigDecimal_power().

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

inline static

Definition at line 1937 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 1914 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 3229 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 1979 of file bigdecimal.c.

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

Referenced by BigDecimal_power().

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

static

Definition at line 165 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_load(), BigDecimal_mod(), BigDecimal_mult(), BigDecimal_mult2(), BigDecimal_neg(), BigDecimal_new(), 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 5601 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 3875 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 3747 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 3552 of file bigdecimal.c.

References BASE_FIG, BDIGIT, 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, VpCtoV(), VpGetPrecLimit(), VpMemAlloc(), VpSetNaN, VpSetNegInf, VpSetPosInf, and VpSetZero.

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

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

Definition at line 3705 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 4550 of file bigdecimal.c.

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

Referenced by BigDecimalCmp().

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

Definition at line 551 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 4971 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 4301 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 5186 of file bigdecimal.c.

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

Referenced by VpSqrt().

static Real * VpDup | ( | Real const *const | x | ) |

static

Definition at line 559 of file bigdecimal.c.

References assert, BDIGIT, Real::exponent, Real::flag, Real::frac, Real::MaxPrec, MEMCPY, NULL, Real::obj, Real::Prec, rb_obj_class(), Real::sign, TypedData_Wrap_Struct, and VpMemAlloc().

Referenced by BigDecimal_new().

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

Definition at line 3290 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(), and VpSqrt().

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

Definition at line 4764 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 4739 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 5695 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 3068 of file bigdecimal.c.

References getchar, NULL, and xfree().

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

VP_EXPORT double VpGetDoubleNaN | ( | void |  | ) |

Definition at line 3249 of file bigdecimal.c.

References Zero().

Referenced by VpInit(), and VpVtoD().

VP_EXPORT double VpGetDoubleNegInf | ( | void |  | ) |

Definition at line 3265 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 3273 of file bigdecimal.c.

References One(), and VpGetDoubleNegInf().

Referenced by VpInit(), and VpVtoD().

VP_EXPORT double VpGetDoublePosInf | ( | void |  | ) |

Definition at line 3257 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 3098 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 3133 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 3168 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 3471 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 5622 of file bigdecimal.c.

References BASE1, 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 3330 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 3184 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 5586 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 5609 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 3054 of file bigdecimal.c.

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

Referenced by VpAlloc(), and VpDup().

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

Definition at line 5426 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 4173 of file bigdecimal.c.

References AddExponent(), BASE, BASE_FIG, BDIGIT, BDIGIT_DBL, 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 543 of file bigdecimal.c.

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

Referenced by BigDecimal_load(), and BigDecimal_new().

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

static

Definition at line 4512 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 3427 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 3502 of file bigdecimal.c.

References VpConstOne.

Referenced by BigDecimal_DoDivmod().

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

Definition at line 5743 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 5670 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 3114 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 3149 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 4078 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 3202 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 5316 of file bigdecimal.c.

References BASE, BASE_FIG, DBLE_FIG, Real::exponent, 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 3966 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 4781 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 4906 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 4827 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 4860 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 5122 of file bigdecimal.c.

References BASE, BASE_FIG, DBLE_FIG, div, Real::exponent, 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 3223 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 153 of file bigdecimal.c.

volatile const double gOne_ABCED9B4_CE73__00400511F31D = 1.0

Definition at line 3221 of file bigdecimal.c.

Referenced by One().

volatile const double gZero_ABCED9B1_CE73__00400511F31D = 0.0

Definition at line 3220 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 3031 of file bigdecimal.c.

Referenced by VpOne().

Real* VpPt5

static

Definition at line 3032 of file bigdecimal.c.