Ruby 1.9.2p136(2010-12-25revision30365)

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

Defines | Functions | Variables

# ext/bigdecimal/bigdecimal.c File Reference

`#include "ruby/ruby.h"`
`#include <ctype.h>`
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include <errno.h>`
`#include <float.h>`
`#include <math.h>`
`#include "bigdecimal.h"`
Include dependency graph for bigdecimal.c:

Go to the source code of this file.

## Defines
#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 | DBLE_FIG (DBL_DIG+1)
#define | DoSomeOne(x, y, f) rb_num_coerce_bin(x,y,f)
#define | maxnr 100UL
#define | MemCmp(x, y, z) memcmp(x,y,z)
#define | StrCmp(x, y) strcmp(x,y)
## Functions
static VALUE | BigDecimal_version (VALUE self)
static unsigned short | VpGetException (void)
static void | VpSetException (unsigned short f)
static void | VpInternalRound (Real *c, U_LONG ixDigit, U_LONG vPrev, U_LONG v)
static int | VpLimitRound (Real *c, U_LONG ixDigit)
static void | BigDecimal_delete (void *pv)
static size_t | BigDecimal_memsize (const void *ptr)
static VALUE | ToValue (Real *p)
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 VALUE | BigDecimal_mode (int argc, VALUE *argv, VALUE self)
static U_LONG | GetAddSubPrec (Real *a, Real *b)
static S_INT | GetPositiveInt (VALUE v)
VP_EXPORT Real * | VpNewRbClass (U_LONG mx, char *str, VALUE klass)
VP_EXPORT Real * | VpCreateRbObject (U_LONG 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_div2 (int argc, VALUE *argv, VALUE self)
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 | BigDecimal_power (VALUE self, VALUE p)
static VALUE | BigDecimal_global_new (int argc, VALUE *argv, VALUE self)
static VALUE | BigDecimal_new (int argc, VALUE *argv, VALUE self)
static VALUE | BigDecimal_limit (int argc, VALUE *argv, VALUE self)
static VALUE | BigDecimal_sign (VALUE self)
void | Init_bigdecimal (void)
static int | VpIsDefOP (Real *c, Real *a, Real *b, int sw)
static int | AddExponent (Real *a, S_INT n)
static U_LONG | VpAddAbs (Real *a, Real *b, Real *c)
static U_LONG | VpSubAbs (Real *a, Real *b, Real *c)
static U_LONG | VpSetPTR (Real *a, Real *b, Real *c, U_LONG *a_pos, U_LONG *b_pos, U_LONG *c_pos, U_LONG *av, U_LONG *bv)
static int | VpNmlz (Real *a)
static void | VpFormatSt (char *psz, S_INT fFmt)
static int | VpRdup (Real *m, U_LONG ind_m)
VP_EXPORT void * | VpMemAlloc (U_LONG mb)
VP_EXPORT void | VpFree (Real *pv)
VP_EXPORT U_LONG | VpGetPrecLimit (void)
VP_EXPORT U_LONG | VpSetPrecLimit (U_LONG n)
VP_EXPORT unsigned long | VpGetRoundMode (void)
VP_EXPORT int | VpIsRoundMode (unsigned long n)
VP_EXPORT unsigned long | VpSetRoundMode (unsigned long n)
static double | Zero (void)
static double | One (void)
VP_EXPORT U_LONG | VpBaseFig (void)
VP_EXPORT U_LONG | VpDblFig (void)
VP_EXPORT U_LONG | VpBaseVal (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 U_LONG | VpNumOfChars (Real *vp, const char *pszFmt)
VP_EXPORT U_LONG | VpInit (U_LONG BaseVal)
VP_EXPORT Real * | VpOne (void)
VP_EXPORT Real * | VpAlloc (U_LONG mx, const char *szVal)
VP_EXPORT U_LONG | VpAsgn (Real *c, Real *a, int isw)
VP_EXPORT U_LONG | VpAddSub (Real *c, Real *a, Real *b, int operation)
VP_EXPORT U_LONG | VpMult (Real *c, Real *a, Real *b)
VP_EXPORT U_LONG | VpDivd (Real *c, Real *r, Real *a, Real *b)
VP_EXPORT int | VpComp (Real *a, Real *b)
VP_EXPORT S_LONG | 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, int fFmt, int fPlus)
VP_EXPORT void | VpToFString (Real *a, char *psz, int fFmt, int fPlus)
VP_EXPORT int | VpCtoV (Real *a, const char *int_chr, U_LONG ni, const char *frac, U_LONG nf, const char *exp_chr, U_LONG ne)
VP_EXPORT int | VpVtoD (double *d, S_LONG *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, int f, S_LONG nf)
VP_EXPORT int | VpLeftRound (Real *y, int f, S_LONG nf)
VP_EXPORT int | VpActiveRound (Real *y, Real *x, int f, S_LONG nf)
VP_EXPORT void | VpFrac (Real *y, Real *x)
VP_EXPORT int | VpPower (Real *y, Real *x, S_INT n)
## Variables
VALUE | rb_cBigDecimal
static U_LONG | BASE_FIG = 4
static U_LONG | BASE = 10000L
static U_LONG | HALF_BASE = 5000L
static U_LONG | BASE1 = 1000L
static const rb_data_type_t | BigDecimal_data_type
static U_LONG | gnPrecLimit = 0
static U_LONG | gfRoundMode = VP_ROUND_HALF_UP
static Real * | VpConstOne
static Real * | VpPt5
static unsigned short | gfDoException = 0
volatile const double | gZero_ABCED9B1_CE73__00400511F31D = 0.0
volatile const double | gOne_ABCED9B4_CE73__00400511F31D = 1.0

## Define Documentation

#define DBLE_FIG (DBL_DIG+1)

Definition at line 57 of file bigdecimal.c.

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

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

Definition at line 63 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 37 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_global_new(), 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 40 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_global_new(), 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 maxnr 100UL

Definition at line 2103 of file bigdecimal.c.

Referenced by VpSqrt().

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

Definition at line 2107 of file bigdecimal.c.

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

Definition at line 38 of file bigdecimal.c.

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

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

Referenced by VpAlloc().

## Function Documentation

static int AddExponent | ( | Real * | a,
|  | S_INT | n
| ) |  | `[static]`

Definition at line 2546 of file bigdecimal.c.

References BASE_FIG, Real::exponent, S_INT, 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 1194 of file bigdecimal.c.

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

Referenced by Init_bigdecimal().

static VALUE BigDecimal_add | ( | VALUE | self,
|  | VALUE | r
| ) |  | `[static]`

Definition at line 632 of file bigdecimal.c.

References DoSomeOne, ENTER, GetAddSubPrec(), GetVpValue(), GUARD_OBJ, Real::obj, SAVE, ToValue(), U_LONG, VpAddSub(), VpBaseFig(), VpCreateRbObject(), VpGetSign, VpIsNaN, and VpSetInf.

Referenced by BigDecimal_add2(), and Init_bigdecimal().

static VALUE BigDecimal_add2 | ( | VALUE | self,
|  | VALUE | b,
|  | VALUE | n
| ) |  | `[static]`

Definition at line 1137 of file bigdecimal.c.

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

Referenced by Init_bigdecimal().

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

Definition at line 1446 of file bigdecimal.c.

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

Referenced by Init_bigdecimal().

static void BigDecimal_check_num | ( | Real * | p | ) | `[static]`

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

References BigDecimal_to_f(), ENTER, GetVpValue(), GUARD_OBJ, Real::obj, rb_assoc_new(), T_FLOAT, and TYPE.

Referenced by Init_bigdecimal().

static VALUE BigDecimal_comp | ( | VALUE | self,
|  | VALUE | r
| ) |  | `[static]`

Definition at line 755 of file bigdecimal.c.

References BigDecimalCmp().

Referenced by Init_bigdecimal().

static void BigDecimal_delete | ( | void * | pv | ) | `[static]`

Definition at line 94 of file bigdecimal.c.

References VpFree().

static VALUE BigDecimal_div | ( | VALUE | self,
|  | VALUE | r
| ) |  | `[static]`

Definition at line 904 of file bigdecimal.c.

References 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 1101 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(), S_INT, ToValue(), U_LONG, VpBaseFig(), VpCreateRbObject(), VpDivd(), VpGetRoundMode(), VpLeftRound(), and VpSetPrecLimit().

Referenced by Init_bigdecimal().

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

Definition at line 865 of file bigdecimal.c.

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

Referenced by BigDecimal_div().

static VALUE BigDecimal_divmod | ( | VALUE | self,
|  | VALUE | r
| ) |  | `[static]`

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

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

References ENTER, Real::exponent, GetAddSubPrec(), GetVpValue(), GUARD_OBJ, NULL, Real::Prec, Qfalse, Qtrue, rb_eZeroDivError, rb_raise(), S_INT, SAVE, U_LONG, 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 194 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 242 of file bigdecimal.c.

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

Referenced by Init_bigdecimal().

static VALUE BigDecimal_eq | ( | VALUE | self,
|  | VALUE | r
| ) |  | `[static]`

Definition at line 771 of file bigdecimal.c.

References BigDecimalCmp().

Referenced by Init_bigdecimal().

static VALUE BigDecimal_exponent | ( | VALUE | self | ) | `[static]`

Definition at line 1622 of file bigdecimal.c.

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

Referenced by Init_bigdecimal().

static VALUE BigDecimal_fix | ( | VALUE | self | ) | `[static]`

Definition at line 1235 of file bigdecimal.c.

References ENTER, GetVpValue(), GUARD_OBJ, Real::Prec, ToValue(), U_LONG, 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 1399 of file bigdecimal.c.

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

Referenced by Init_bigdecimal().

static VALUE BigDecimal_frac | ( | VALUE | self | ) | `[static]`

Definition at line 1366 of file bigdecimal.c.

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

Referenced by Init_bigdecimal().

static VALUE BigDecimal_ge | ( | VALUE | self,
|  | VALUE | r
| ) |  | `[static]`

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

References ENTER, GetPositiveInt(), GUARD_OBJ, rb_scan_args(), RSTRING_PTR, S_LONG, SafeStringValue, ToValue(), and VpCreateRbObject().

Referenced by Init_bigdecimal().

static VALUE BigDecimal_gt | ( | VALUE | self,
|  | VALUE | r
| ) |  | `[static]`

Definition at line 807 of file bigdecimal.c.

References BigDecimalCmp().

Referenced by Init_bigdecimal().

static VALUE BigDecimal_hash | ( | VALUE | self | ) | `[static]`

Definition at line 222 of file bigdecimal.c.

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

Referenced by Init_bigdecimal().

static VALUE BigDecimal_inspect | ( | VALUE | self | ) | `[static]`

Definition at line 1639 of file bigdecimal.c.

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

Referenced by Init_bigdecimal().

static VALUE BigDecimal_IsFinite | ( | VALUE | self | ) | `[static]`

Definition at line 456 of file bigdecimal.c.

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

Referenced by Init_bigdecimal().

static VALUE BigDecimal_IsInfinite | ( | VALUE | self | ) | `[static]`

Definition at line 446 of file bigdecimal.c.

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

Referenced by Init_bigdecimal().

static VALUE BigDecimal_IsNaN | ( | VALUE | self | ) | `[static]`

Definition at line 435 of file bigdecimal.c.

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

Referenced by Init_bigdecimal().

static VALUE BigDecimal_le | ( | VALUE | self,
|  | VALUE | r
| ) |  | `[static]`

Definition at line 795 of file bigdecimal.c.

References BigDecimalCmp().

Referenced by Init_bigdecimal().

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

Definition at line 1757 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 264 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 783 of file bigdecimal.c.

References BigDecimalCmp().

Referenced by Init_bigdecimal().

static size_t BigDecimal_memsize | ( | const void * | ptr | ) | `[static]`

Definition at line 100 of file bigdecimal.c.

References Real::MaxPrec, and U_LONG.

static VALUE BigDecimal_mod | ( | VALUE | self,
|  | VALUE | r
| ) |  | `[static]`

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

References Check_Type, FIX2INT, INT2FIX, Qfalse, Qnil, Qtrue, 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(), VpIsRoundMode(), VpSetException(), and VpSetRoundMode().

Referenced by Init_bigdecimal().

static VALUE BigDecimal_mult | ( | VALUE | self,
|  | VALUE | r
| ) |  | `[static]`

Definition at line 847 of file bigdecimal.c.

References DoSomeOne, ENTER, GetVpValue(), GUARD_OBJ, Real::Prec, SAVE, ToValue(), U_LONG, VpBaseFig(), VpCreateRbObject(), and VpMult().

Referenced by BigDecimal_mult2(), and Init_bigdecimal().

static VALUE BigDecimal_mult2 | ( | VALUE | self,
|  | VALUE | b,
|  | VALUE | n
| ) |  | `[static]`

Definition at line 1171 of file bigdecimal.c.

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

Referenced by Init_bigdecimal().

static VALUE BigDecimal_neg | ( | VALUE | self | ) | `[static]`

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

References ENTER, GetPositiveInt(), GUARD_OBJ, rb_scan_args(), RSTRING_PTR, S_LONG, SafeStringValue, ToValue(), and VpNewRbClass().

Referenced by Init_bigdecimal().

static VALUE BigDecimal_nonzero | ( | VALUE | self | ) | `[static]`

Definition at line 745 of file bigdecimal.c.

References GetVpValue(), Qnil, and VpIsZero.

Referenced by Init_bigdecimal().

static VALUE BigDecimal_power | ( | VALUE | self,
|  | VALUE | p
| ) |  | `[static]`

Definition at line 1670 of file bigdecimal.c.

References Check_Type, ENTER, FIX2INT, GetVpValue(), GUARD_OBJ, Real::Prec, S_INT, S_LONG, T_FIXNUM, ToValue(), VpBaseFig(), VpCreateRbObject(), VpIsDef, and VpPower().

Referenced by Init_bigdecimal().

static VALUE BigDecimal_prec | ( | VALUE | self | ) | `[static]`

Definition at line 209 of file bigdecimal.c.

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

Referenced by Init_bigdecimal().

static VALUE BigDecimal_remainder | ( | VALUE | self,
|  | VALUE | r
| ) |  | `[static]`

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

References BigDecimal_to_i(), Check_Type, ENTER, FIX2INT, GetVpValue(), GUARD_OBJ, Real::Prec, Qnil, rb_eTypeError, rb_raise(), rb_scan_args(), T_FIXNUM, ToValue(), U_LONG, VpActiveRound(), VpBaseFig(), VpCreateRbObject(), VpGetRoundMode(), VpIsRoundMode(), and VpSetPrecLimit().

Referenced by Init_bigdecimal().

static VALUE BigDecimal_sign | ( | VALUE | self | ) | `[static]`

Definition at line 1792 of file bigdecimal.c.

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

Referenced by Init_bigdecimal().

static VALUE BigDecimal_split | ( | VALUE | self | ) | `[static]`

Definition at line 1584 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, S_LONG, 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 1216 of file bigdecimal.c.

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

Referenced by Init_bigdecimal().

static VALUE BigDecimal_sub | ( | VALUE | self,
|  | VALUE | r
| ) |  | `[static]`

Definition at line 670 of file bigdecimal.c.

References DoSomeOne, ENTER, GetAddSubPrec(), GetVpValue(), GUARD_OBJ, Real::obj, SAVE, ToValue(), U_LONG, VpAddSub(), VpBaseFig(), VpCreateRbObject(), VpGetSign, VpIsNaN, and VpSetInf.

Referenced by BigDecimal_sub2(), and Init_bigdecimal().

static VALUE BigDecimal_sub2 | ( | VALUE | self,
|  | VALUE | b,
|  | VALUE | n
| ) |  | `[static]`

Definition at line 1154 of file bigdecimal.c.

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

Referenced by Init_bigdecimal().

static VALUE BigDecimal_to_f | ( | VALUE | self | ) | `[static]`

Definition at line 524 of file bigdecimal.c.

References BASE_FIG, buf, DBL_MAX_10_EXP, ENTER, errno, GetVpValue(), GUARD_OBJ, rb_float_new(), rb_str_new(), RSTRING_PTR, S_LONG, strtod, VP_EXCEPTION_OVERFLOW, 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 483 of file bigdecimal.c.

References BigDecimal_check_num(), BigDecimal_split(), ENTER, Real::frac, GetVpValue(), GUARD_OBJ, INT2FIX, RARRAY_PTR, rb_funcall(), rb_intern, RSTRING_LEN, S_LONG, VpBaseFig(), VpExponent10(), and VpGetSign.

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

static VALUE BigDecimal_to_r | ( | VALUE | self | ) | `[static]`

Definition at line 554 of file bigdecimal.c.

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

Referenced by Init_bigdecimal().

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

Definition at line 1504 of file bigdecimal.c.

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

Referenced by Init_bigdecimal().

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

Definition at line 1336 of file bigdecimal.c.

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

Referenced by Init_bigdecimal().

static VALUE BigDecimal_uplus | ( | VALUE | self | ) | `[static]`

Definition at line 615 of file bigdecimal.c.

Referenced by Init_bigdecimal().

static VALUE BigDecimal_version | ( | VALUE | self | ) | `[static]`

Definition at line 72 of file bigdecimal.c.

References rb_str_new2().

Referenced by Init_bigdecimal().

static VALUE BigDecimal_zero | ( | VALUE | self | ) | `[static]`

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

References ENTER, GetVpValue(), GUARD_OBJ, INT2FIX, Qfalse, Qnil, Qtrue, rb_bug(), rb_intern, rb_num_coerce_cmp(), rb_num_coerce_relop(), RTEST, S_INT, SAVE, and VpComp().

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

static U_LONG GetAddSubPrec | ( | Real * | a,
|  | Real * | b
| ) |  | `[static]`

Definition at line 385 of file bigdecimal.c.

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

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

static S_INT GetPositiveInt | ( | VALUE | v | ) | `[static]`

Definition at line 406 of file bigdecimal.c.

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

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

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

Definition at line 125 of file bigdecimal.c.

References DATA_PTR, FIX2LONG, NULL, Qundef, rb_big2str(), rb_eTypeError, rb_funcall2(), rb_inspect(), rb_intern, rb_obj_classname(), rb_raise(), rb_require(), rb_special_const_p(), rb_typeddata_is_kind_of(), RSTRING_PTR, SafeStringValue, T_BIGNUM, T_DATA, T_FIXNUM, T_RATIONAL, T_STRING, TYPE, VpBaseFig(), and VpCreateRbObject().

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_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(), and BigDecimalCmp().

void Init_bigdecimal | ( | void |  | ) |

Definition at line 1903 of file bigdecimal.c.

References 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_prec(), BigDecimal_remainder(), 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_uplus(), BigDecimal_version(), BigDecimal_zero(), INT2FIX, rb_cBigDecimal, rb_cNumeric, rb_define_class(), rb_define_const(), rb_define_global_function(), rb_define_method(), rb_define_singleton_method(), S_INT, U_LONG, 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 double One | ( | void |  | ) | `[static]`

Definition at line 2229 of file bigdecimal.c.

References gOne_ABCED9B4_CE73__00400511F31D.

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

static VALUE ToValue | ( | Real * | p | ) | `[static]`

Definition at line 112 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_load(), BigDecimal_mod(), BigDecimal_mult(), BigDecimal_mult2(), BigDecimal_neg(), BigDecimal_new(), BigDecimal_power(), BigDecimal_remainder(), BigDecimal_round(), BigDecimal_sqrt(), BigDecimal_sub(), BigDecimal_sub2(), and BigDecimal_truncate().

VP_EXPORT int VpActiveRound | ( | Real * | y,
|  | Real * | x,
|  | int | f,
|  | S_LONG | nf
| ) |  |

Definition at line 4589 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 U_LONG VpAddAbs | ( | Real * | a,
|  | Real * | b,
|  | Real * | c
| ) |  | `[static]`

Definition at line 2910 of file bigdecimal.c.

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

Referenced by VpAddSub().

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

Definition at line 2782 of file bigdecimal.c.

References BASE_FIG, Real::exponent, Real::frac, Min, Real::Prec, S_INT, U_LONG, 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 | ( | U_LONG | mx,
|  | const char * | szVal
| ) |  |

Definition at line 2589 of file bigdecimal.c.

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

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

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

Definition at line 2740 of file bigdecimal.c.

References BASE_FIG, Real::exponent, Real::frac, Real::MaxPrec, Real::Prec, U_LONG, 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 U_LONG VpBaseFig | ( | void |  | ) |

Definition at line 2235 of file bigdecimal.c.

References BASE_FIG.

Referenced by BigDecimal_abs(), BigDecimal_add(), BigDecimal_ceil(), BigDecimal_div2(), BigDecimal_divide(), BigDecimal_divremain(), BigDecimal_DoDivmod(), BigDecimal_dump(), BigDecimal_fix(), BigDecimal_floor(), BigDecimal_frac(), BigDecimal_inspect(), BigDecimal_load(), BigDecimal_mult(), BigDecimal_neg(), BigDecimal_power(), BigDecimal_prec(), BigDecimal_round(), BigDecimal_sqrt(), BigDecimal_sub(), BigDecimal_to_i(), BigDecimal_truncate(), and GetVpValue().

VP_EXPORT U_LONG VpBaseVal | ( | void |  | ) |

Definition at line 2247 of file bigdecimal.c.

References BASE.

Referenced by BigDecimal_div(), and Init_bigdecimal().

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

Definition at line 3586 of file bigdecimal.c.

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

Referenced by BigDecimalCmp().

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

Definition at line 426 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_global_new(), BigDecimal_mult(), BigDecimal_neg(), BigDecimal_power(), BigDecimal_round(), BigDecimal_sqrt(), BigDecimal_sub(), BigDecimal_truncate(), and GetVpValue().

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

Definition at line 4010 of file bigdecimal.c.

References BASE_FIG, Real::exponent, Real::frac, Real::MaxPrec, ne, Real::Prec, rb_warn(), S_INT, S_LONG, U_LONG, VP_EXCEPTION_INFINITY, VpException(), VpNmlz(), VpSetInf, VpSetSign, VpSetZero, and zero().

Referenced by VpAlloc().

VP_EXPORT U_LONG VpDblFig | ( | void |  | ) |

Definition at line 2241 of file bigdecimal.c.

References DBLE_FIG.

Referenced by BigDecimal_double_fig(), and BigDecimal_sqrt().

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

Definition at line 3338 of file bigdecimal.c.

References AddExponent(), BASE, BASE_FIG, Real::exponent, Real::frac, Real::MaxPrec, Min, Real::Prec, rb_bug(), U_LONG, 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 4223 of file bigdecimal.c.

References BASE, Real::exponent, Real::frac, isinf(), isnan, Real::MaxPrec, ne, Real::Prec, S_INT, U_LONG, 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 2308 of file bigdecimal.c.

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

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

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

Definition at line 3803 of file bigdecimal.c.

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

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

static void VpFormatSt | ( | char * | psz,
|  | S_INT | fFmt
| ) |  | `[static]`

Definition at line 3776 of file bigdecimal.c.

References ISSPACE, memmove(), S_INT, and U_LONG.

Referenced by VpToFString(), and VpToString().

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

Definition at line 4674 of file bigdecimal.c.

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

Referenced by BigDecimal_divremain(), and BigDecimal_frac().

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

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

References Zero().

Referenced by VpInit(), and VpVtoD().

VP_EXPORT double VpGetDoubleNegInf | ( | void |  | ) |

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

References One(), and VpGetDoubleNegInf().

Referenced by VpInit(), and VpVtoD().

VP_EXPORT double VpGetDoublePosInf | ( | void |  | ) |

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

References gfDoException.

Referenced by BigDecimal_mode().

VP_EXPORT U_LONG VpGetPrecLimit | ( | void |  | ) |

Definition at line 2175 of file bigdecimal.c.

References gnPrecLimit.

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

VP_EXPORT unsigned long VpGetRoundMode | ( | void |  | ) |

Definition at line 2189 of file bigdecimal.c.

References gfRoundMode.

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

VP_EXPORT U_LONG VpInit | ( | U_LONG | BaseVal | ) |

Definition at line 2487 of file bigdecimal.c.

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

Referenced by Init_bigdecimal().

static void VpInternalRound | ( | Real * | c,
|  | U_LONG | ixDigit,
|  | U_LONG | vPrev,
|  | U_LONG | v
| ) |  | `[static]`

Definition at line 4608 of file bigdecimal.c.

References BASE1, gfRoundMode, 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, 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 2347 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 long | n | ) |

Definition at line 2195 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 BigDecimal_mode(), BigDecimal_round(), and VpSetRoundMode().

VP_EXPORT int VpLeftRound | ( | Real * | y,
|  | int | f,
|  | S_LONG | nf
| ) |  |

Definition at line 4574 of file bigdecimal.c.

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

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

static int VpLimitRound | ( | Real * | c,
|  | U_LONG | ixDigit
| ) |  | `[static]`

Definition at line 4597 of file bigdecimal.c.

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

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

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

Definition at line 2124 of file bigdecimal.c.

References VP_EXCEPTION_MEMORY, VpException(), and xmalloc.

Referenced by VpAlloc().

VP_EXPORT int VpMidRound | ( | Real * | y,
|  | int | f,
|  | S_LONG | nf
| ) |  |

Definition at line 4465 of file bigdecimal.c.

References BASE, BASE_FIG, div, Real::exponent, Real::frac, Real::Prec, S_INT, S_LONG, U_LONG, 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 U_LONG VpMult | ( | Real * | c,
|  | Real * | a,
|  | Real * | b
| ) |  |

Definition at line 3211 of file bigdecimal.c.

References AddExponent(), BASE, BASE_FIG, Real::exponent, Real::frac, Real::MaxPrec, NULL, Real::Prec, U_LONG, 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 | ( | U_LONG | mx,
|  | char * | str,
|  | VALUE | klass
| ) |  |

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

References AddExponent(), Real::frac, memmove(), Real::Prec, S_INT, U_LONG, VpGetSign, VpIsDef, VpIsZero, and VpSetZero.

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

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

Definition at line 2444 of file bigdecimal.c.

References BASE_FIG, Real::exponent, NULL, Real::Prec, S_INT, U_LONG, 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 2539 of file bigdecimal.c.

References VpConstOne.

Referenced by BigDecimal_DoDivmod().

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

Definition at line 4719 of file bigdecimal.c.

References BASE_FIG, Real::exponent, Real::frac, Real::MaxPrec, NULL, Real::Prec, S_INT, S_LONG, U_LONG, 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,
|  | U_LONG | ind_m
| ) |  | `[static]`

Definition at line 4649 of file bigdecimal.c.

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

Referenced by VpInternalRound(), and VpMidRound().

static void VpSetException | ( | unsigned short | f | ) | `[static]`

Definition at line 2168 of file bigdecimal.c.

References gfDoException.

Referenced by BigDecimal_mode().

VP_EXPORT U_LONG VpSetPrecLimit | ( | U_LONG | n | ) |

Definition at line 2181 of file bigdecimal.c.

References gnPrecLimit, and U_LONG.

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

static U_LONG VpSetPTR | ( | Real * | a,
|  | Real * | b,
|  | Real * | c,
|  | U_LONG * | a_pos,
|  | U_LONG * | b_pos,
|  | U_LONG * | c_pos,
|  | U_LONG * | av,
|  | U_LONG * | bv
| ) |  | `[static]`

Definition at line 3116 of file bigdecimal.c.

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

Referenced by VpAddAbs(), and VpSubAbs().

VP_EXPORT unsigned long VpSetRoundMode | ( | unsigned long | n | ) |

Definition at line 2206 of file bigdecimal.c.

References gfRoundMode, and VpIsRoundMode().

Referenced by BigDecimal_mode().

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

Definition at line 4356 of file bigdecimal.c.

References BASE, BASE_FIG, DBLE_FIG, Real::exponent, maxnr, Real::MaxPrec, Min, NULL, S_INT, S_LONG, U_LONG, 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 U_LONG VpSubAbs | ( | Real * | a,
|  | Real * | b,
|  | Real * | c
| ) |  | `[static]`

Definition at line 3002 of file bigdecimal.c.

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

Referenced by VpAddSub().

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

Definition at line 3820 of file bigdecimal.c.

References BASE1, Real::frac, Real::Prec, SZ_INF, SZ_NaN, SZ_NINF, U_LONG, VpGetSign, VpIsNaN, VpIsNegInf, VpIsPosInf, VpIsPosZero, and VpIsZero.

Referenced by BigDecimal_split().

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

Definition at line 3945 of file bigdecimal.c.

References BASE, BASE1, BASE_FIG, Real::exponent, Real::frac, Real::Prec, S_LONG, U_LONG, VpFormatSt(), VpGetSign, and VpToSpecialString().

Referenced by BigDecimal_to_s().

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

Definition at line 3866 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,
|  | int | fFmt,
|  | int | fPlus
| ) |  |

Definition at line 3899 of file bigdecimal.c.

References BASE1, BASE_FIG, Real::exponent, Real::frac, Real::Prec, S_LONG, U_LONG, VpFormatSt(), VpGetSign, and VpToSpecialString().

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

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

Definition at line 4159 of file bigdecimal.c.

References BASE, BASE_FIG, DBLE_FIG, div, Real::exponent, Real::frac, Min, Real::Prec, S_INT, U_LONG, 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 2223 of file bigdecimal.c.

References gZero_ABCED9B1_CE73__00400511F31D.

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

## Variable Documentation

U_LONG BASE = 10000L`[static]`

Definition at line 44 of file bigdecimal.c.

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

U_LONG BASE1 = 1000L`[static]`

Definition at line 48 of file bigdecimal.c.

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

U_LONG BASE_FIG = 4`[static]`

Definition at line 43 of file bigdecimal.c.

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

const rb_data_type_t BigDecimal_data_type`[static]`

Initial value:

     {
        "BigDecimal",
        0, BigDecimal_delete, BigDecimal_memsize,
    }

Definition at line 106 of file bigdecimal.c.

unsigned short gfDoException = 0`[static]`

Definition at line 2159 of file bigdecimal.c.

Referenced by VpException(), VpGetException(), and VpSetException().

U_LONG gfRoundMode = VP_ROUND_HALF_UP`[static]`

Definition at line 2099 of file bigdecimal.c.

Referenced by VpGetRoundMode(), VpInternalRound(), and VpSetRoundMode().

U_LONG gnPrecLimit = 0`[static]`

Definition at line 2098 of file bigdecimal.c.

Referenced by VpGetPrecLimit(), and VpSetPrecLimit().

volatile const double gOne_ABCED9B4_CE73__00400511F31D = 1.0

Definition at line 2221 of file bigdecimal.c.

Referenced by One().

volatile const double gZero_ABCED9B1_CE73__00400511F31D = 0.0

Definition at line 2220 of file bigdecimal.c.

Referenced by Zero().

U_LONG HALF_BASE = 5000L`[static]`

Definition at line 47 of file bigdecimal.c.

Referenced by VpInit().

VALUE rb_cBigDecimal

Definition at line 32 of file bigdecimal.c.

Referenced by Init_bigdecimal(), and VpCreateRbObject().

Real* VpConstOne`[static]`

Definition at line 2101 of file bigdecimal.c.

Referenced by VpOne().

Real* VpPt5`[static]`

Definition at line 2102 of file bigdecimal.c.