Ruby: ext/bigdecimal/bigdecimal.c File Reference

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

Macros | Enumerations | Functions | Variables
bigdecimal.c File Reference
`#include "bigdecimal.h"`
`#include "ruby/util.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 | MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, min, max)
#define | SIGNED_VALUE_MAX INTPTR_MAX
#define | SIGNED_VALUE_MIN INTPTR_MIN
#define | MUL_OVERFLOW_SIGNED_VALUE_P(a, b) MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, SIGNED_VALUE_MIN, SIGNED_VALUE_MAX)
#define | ENTER(n) volatile VALUE RB_UNUSED_VAR(vStack[n]);int iStack=0
#define | PUSH(x) (vStack[iStack++] = (VALUE)(x))
#define | SAVE(p) PUSH((p)->obj)
#define | GUARD_OBJ(p, y) ((p)=(y), SAVE(p))
#define | BASE_FIG RMPD_COMPONENT_FIGURES
#define | BASE RMPD_BASE
#define | HALF_BASE (BASE/2)
#define | BASE1 (BASE/10)
#define | DBLE_FIG rmpd_double_figures() /* figure of double */
#define | RRATIONAL_ZERO_P(x)
#define | RRATIONAL_NEGATIVE_P(x) RTEST(rb_funcall((x), '<', 1, INT2FIX(0)))
#define | RB_OBJ_CLASSNAME(obj) rb_obj_class(obj)
#define | RB_OBJ_STRING(obj) (obj)
#define | BIGDECIMAL_POSITIVE_P(bd) ((bd)->sign > 0)
#define | BIGDECIMAL_NEGATIVE_P(bd) ((bd)->sign < 0)
#define | DoSomeOne(x, y, f) rb_num_coerce_bin(x,y,f)
#define | VpAllocReal(prec) (Real *)VpMemAlloc(offsetof(Real, frac) + (prec) * sizeof(BDIGIT))
#define | VpReallocReal(ptr, prec) (Real *)VpMemRealloc((ptr), offsetof(Real, frac) + (prec) * sizeof(BDIGIT))
#define | BigMath_exp(x, n) BigMath_s_exp(rb_mBigMath, (x), (n))
#define | BigMath_log(x, n) BigMath_s_log(rb_mBigMath, (x), (n))
#define | is_positive(x) (!is_negative(x))
#define | maxnr 100UL /* Maximum iterations for calculating 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)

## Enumerations
enum | op_sw { OP_SW_ADD = 1 , OP_SW_SUB , OP_SW_MULT , OP_SW_DIV }

## Functions
VP_EXPORT Real * | VpNewRbClass (size_t mx, const char *str, VALUE klass)
VP_EXPORT Real * | VpCreateRbObject (size_t mx, const char *str)
void | Init_bigdecimal (void)
VP_EXPORT void * | VpMemAlloc (size_t mb)
VP_EXPORT void * | VpMemRealloc (void *ptr, size_t mb)
VP_EXPORT void | VpFree (Real *pv)
VP_EXPORT size_t | VpGetPrecLimit (void)
VP_EXPORT size_t | VpSetPrecLimit (size_t n)
VP_EXPORT unsigned short | VpGetRoundMode (void)
VP_EXPORT int | VpIsRoundMode (unsigned short n)
VP_EXPORT unsigned short | VpSetRoundMode (unsigned short n)
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)
Real * | rmpd_parse_special_string (const char *str)
VP_EXPORT Real * | VpAlloc (size_t mx, const char *szVal, int strict_p, int exc)
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
volatile const double | gOne_ABCED9B4_CE73__00400511F31D = 1.0

## Macro Definition Documentation

## ◆ BASE

#define BASE RMPD_BASE

Definition at line 74 of file bigdecimal.c.

## ◆ BASE1

#define BASE1 (BASE/10)

Definition at line 77 of file bigdecimal.c.

## ◆ BASE_FIG

#define BASE_FIG RMPD_COMPONENT_FIGURES

Definition at line 73 of file bigdecimal.c.

## ◆ BIGDECIMAL_NEGATIVE_P

#define BIGDECIMAL_NEGATIVE_P | ( |  | bd | ) | ((bd)->sign < 0)

Definition at line 155 of file bigdecimal.c.

## ◆ BIGDECIMAL_POSITIVE_P

#define BIGDECIMAL_POSITIVE_P | ( |  | bd | ) | ((bd)->sign > 0)

Definition at line 154 of file bigdecimal.c.

## ◆ BigMath_exp

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

Definition at line 2307 of file bigdecimal.c.

## ◆ BigMath_log

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

Definition at line 2308 of file bigdecimal.c.

## ◆ DBLE_FIG

#define DBLE_FIG rmpd_double_figures() /* figure of double */

Definition at line 80 of file bigdecimal.c.

## ◆ DoSomeOne

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

Definition at line 160 of file bigdecimal.c.

## ◆ ENTER

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

Definition at line 68 of file bigdecimal.c.

## ◆ GUARD_OBJ

#define GUARD_OBJ | ( |  | p,
|  |  | y
| ) |  | ((p)=(y), SAVE(p))

Definition at line 71 of file bigdecimal.c.

## ◆ HALF_BASE

#define HALF_BASE (BASE/2)

Definition at line 76 of file bigdecimal.c.

## ◆ is_positive

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

Definition at line 2331 of file bigdecimal.c.

## ◆ maxnr

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

Definition at line 3705 of file bigdecimal.c.

## ◆ MemCmp

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

Definition at line 3709 of file bigdecimal.c.

## ◆ MUL_OVERFLOW_SIGNED_INTEGER_P

#define MUL_OVERFLOW_SIGNED_INTEGER_P | ( |  | a,
|  |  | b,
|  |  | min,
|  |  | max
| ) |  |

Value:
( \
(a) == 0 ? 0 : \
(a) == -1 ? (b) < -(max) : \
(a) > 0 ? \
((b) > 0 ? (max) / (a) < (b) : (min) / (a) > (b)) : \
((b) > 0 ? (min) / (a) < (b) : (max) / (a) > (b)))
max
int max
Definition: enough.c:225

Definition at line 35 of file bigdecimal.c.

## ◆ MUL_OVERFLOW_SIGNED_VALUE_P

#define MUL_OVERFLOW_SIGNED_VALUE_P | ( |  | a,
|  |  | b
| ) |  | MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, SIGNED_VALUE_MIN, SIGNED_VALUE_MAX)

Definition at line 43 of file bigdecimal.c.

## ◆ NDEBUG

#define NDEBUG

Definition at line 18 of file bigdecimal.c.

## ◆ PUSH

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

Definition at line 69 of file bigdecimal.c.

## ◆ RB_OBJ_CLASSNAME

#define RB_OBJ_CLASSNAME | ( |  | obj | ) | rb_obj_class(obj)

Definition at line 98 of file bigdecimal.c.

## ◆ RB_OBJ_STRING

#define RB_OBJ_STRING | ( |  | obj | ) | (obj)

Definition at line 99 of file bigdecimal.c.

## ◆ RMPD_PRECISION_LIMIT_DEFAULT

#define RMPD_PRECISION_LIMIT_DEFAULT ((size_t)0)

Definition at line 3821 of file bigdecimal.c.

## ◆ rmpd_set_thread_local_exception_mode

#define rmpd_set_thread_local_exception_mode | ( |  | mode | ) |

Value:
rb_thread_local_aset( \
rb_thread_current(), \
id_BigDecimal_exception_mode, \
INT2FIX((int)(mode)) \
)
rb_thread_current
VALUE rb_thread_current(void)
Definition: thread.c:2911
rb_thread_local_aset
VALUE rb_thread_local_aset(VALUE, ID, VALUE)
Definition: thread.c:3628
mode
const char int mode
Definition: ioapi.h:137
INT2FIX
#define INT2FIX
Definition: long.h:48

Definition at line 3782 of file bigdecimal.c.

## ◆ rmpd_set_thread_local_precision_limit

#define rmpd_set_thread_local_precision_limit | ( |  | limit | ) |

Value:
rb_thread_local_aset( \
rb_thread_current(), \
id_BigDecimal_precision_limit, \
SIZET2NUM(limit) \
)
SIZET2NUM
#define SIZET2NUM
Definition: size_t.h:52

Definition at line 3815 of file bigdecimal.c.

## ◆ rmpd_set_thread_local_rounding_mode

#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 3852 of file bigdecimal.c.

## ◆ RRATIONAL_NEGATIVE_P

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

Definition at line 89 of file bigdecimal.c.

## ◆ RRATIONAL_ZERO_P

#define RRATIONAL_ZERO_P | ( |  | x | ) |

Value:
(FIXNUM_P(rb_rational_num(x)) && \
FIX2LONG(rb_rational_num(x)) == 0)
FIXNUM_P
#define FIXNUM_P
Definition: special_consts.h:44

Definition at line 84 of file bigdecimal.c.

## ◆ SAVE

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

Definition at line 70 of file bigdecimal.c.

## ◆ SIGNED_VALUE_MAX

#define SIGNED_VALUE_MAX INTPTR_MAX

Definition at line 41 of file bigdecimal.c.

## ◆ SIGNED_VALUE_MIN

#define SIGNED_VALUE_MIN INTPTR_MIN

Definition at line 42 of file bigdecimal.c.

## ◆ StrCmp

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

Definition at line 3710 of file bigdecimal.c.

## ◆ VpAllocReal

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

Definition at line 788 of file bigdecimal.c.

## ◆ VpReallocReal

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

Definition at line 789 of file bigdecimal.c.

## Enumeration Type Documentation

## ◆ op_sw

enum op_sw

Enumerator
OP_SW_ADD |
OP_SW_SUB |
OP_SW_MULT |
OP_SW_DIV |

Definition at line 3712 of file bigdecimal.c.

## Function Documentation

## ◆ Init_bigdecimal()

void Init_bigdecimal | ( | void |  | ) |

Definition at line 3456 of file bigdecimal.c.

References CLASS_OF, id_ceil, id_eq, id_to_r, 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_ext_ractor_safe(), rb_mBigMath, rb_str_new2, rb_undef_alloc_func(), rb_undef_method(), 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().

## ◆ rmpd_parse_special_string()

Real * rmpd_parse_special_string | ( | const char * | str | ) |

Definition at line 4213 of file bigdecimal.c.

References ISSPACE, len, Real::MaxPrec, NULL, str, SZ_INF, SZ_NaN, SZ_NINF, SZ_PINF, UNREACHABLE, VP_SIGN_NaN, VP_SIGN_NEGATIVE_INFINITE, VP_SIGN_POSITIVE_INFINITE, VpAllocReal, VpSetNaN, VpSetNegInf, and VpSetPosInf.

Referenced by VpAlloc().

## ◆ VpActiveRound()

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

Definition at line 6466 of file bigdecimal.c.

References f, VpAsgn(), and VpMidRound().

## ◆ VpAddSub()

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

Definition at line 4549 of file bigdecimal.c.

References BASE_FIG, BDIGIT, Real::exponent, Real::frac, Min, OP_SW_ADD, OP_SW_SUB, Real::Prec, VpAsgn(), VpGetSign, VpIsZero, VpSetSign, and VpSetZero.

Referenced by VpSqrt().

## ◆ VpAlloc()

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

Definition at line 4272 of file bigdecimal.c.

References BASE_FIG, ISDIGIT, ISSPACE, Max, Real::MaxPrec, ne, NULL, PRIsVALUE, rb_eArgError, rb_raise(), rb_str_new2, rb_str_resize(), rb_str_tmp_new(), rmpd_parse_special_string(), RSTRING_PTR, str, strlen(), VpAllocReal, VpCtoV(), VpGetPrecLimit(), and VpSetZero.

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

## ◆ VpAsgn()

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

Definition at line 4505 of file bigdecimal.c.

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

Referenced by VpActiveRound(), VpAddSub(), VpDivd(), VpFrac(), VpMult(), VpPower(), and VpSqrt().

## ◆ VpComp()

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

Definition at line 5386 of file bigdecimal.c.

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

## ◆ VpCreateRbObject()

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

Definition at line 783 of file bigdecimal.c.

References rb_cBigDecimal, str, and VpNewRbClass().

## ◆ VpCtoV()

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

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

Referenced by VpAlloc().

## ◆ VpDivd()

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

Definition at line 5133 of file bigdecimal.c.

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

Referenced by VpPower(), and VpSqrt().

## ◆ VpDtoV()

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

Definition at line 6048 of file bigdecimal.c.

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

Referenced by VpSqrt().

## ◆ VpException()

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

Definition at line 3970 of file bigdecimal.c.

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

Referenced by VpCtoV(), VpDivd(), VpMemAlloc(), VpMemRealloc(), and VpSqrt().

## ◆ VpExponent10()

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

Definition at line 5611 of file bigdecimal.c.

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

## ◆ VpFrac()

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

Definition at line 6561 of file bigdecimal.c.

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

## ◆ VpFree()

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

Definition at line 3760 of file bigdecimal.c.

References NULL, and xfree.

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

## ◆ VpGetDoubleNaN()

VP_EXPORT double VpGetDoubleNaN | ( | void |  | ) |

Definition at line 3935 of file bigdecimal.c.

References nan().

Referenced by VpVtoD().

## ◆ VpGetDoubleNegInf()

VP_EXPORT double VpGetDoubleNegInf | ( | void |  | ) |

Definition at line 3947 of file bigdecimal.c.

References HUGE_VAL.

Referenced by VpGetDoubleNegZero(), and VpVtoD().

## ◆ VpGetDoubleNegZero()

VP_EXPORT double VpGetDoubleNegZero | ( | void |  | ) |

Definition at line 3953 of file bigdecimal.c.

References VpGetDoubleNegInf().

Referenced by VpInit(), and VpVtoD().

## ◆ VpGetDoublePosInf()

VP_EXPORT double VpGetDoublePosInf | ( | void |  | ) |

Definition at line 3941 of file bigdecimal.c.

References HUGE_VAL.

Referenced by VpVtoD().

## ◆ VpGetPrecLimit()

VP_EXPORT size_t VpGetPrecLimit | ( | void |  | ) |

Definition at line 3825 of file bigdecimal.c.

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

Referenced by VpAlloc(), and VpSetPrecLimit().

## ◆ VpGetRoundMode()

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

Definition at line 3860 of file bigdecimal.c.

References NIL_P, NUM2USHORT, rb_thread_current(), rb_thread_local_aref(), RMPD_ROUNDING_MODE_DEFAULT, and rmpd_set_thread_local_rounding_mode.

Referenced by VpSetRoundMode().

## ◆ VpInit()

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

Definition at line 4141 of file bigdecimal.c.

References BASE, BASE1, BASE_FIG, DBLE_FIG, HALF_BASE, PRIuBDIGIT, VpAlloc(), and VpGetDoubleNegZero().

Referenced by Init_bigdecimal().

## ◆ VpIsRoundMode()

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

Definition at line 3876 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 VpSetRoundMode().

## ◆ VpLeftRound()

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

Definition at line 6451 of file bigdecimal.c.

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

## ◆ VpMemAlloc()

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

Definition at line 3736 of file bigdecimal.c.

References VP_EXCEPTION_MEMORY, VpException(), and xmalloc.

## ◆ VpMemRealloc()

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

Definition at line 3750 of file bigdecimal.c.

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

## ◆ VpMidRound()

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

Definition at line 6289 of file bigdecimal.c.

References BASE, BASE_FIG, BDIGIT, BIGDECIMAL_NEGATIVE_P, BIGDECIMAL_POSITIVE_P, div, Real::exponent, f, Real::frac, Real::Prec, SIGNED_VALUE, 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, VpSetOne, VpSetSign, and VpSetZero.

Referenced by VpActiveRound(), and VpLeftRound().

## ◆ VpMult()

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

Definition at line 5004 of file bigdecimal.c.

References BASE, BASE_FIG, BDIGIT, BDIGIT_DBL, Real::exponent, Real::frac, Real::MaxPrec, NULL, OP_SW_MULT, Real::Prec, VpAlloc(), VpAsgn(), VpFree(), VpGetSign, VpIsOne, VpIsZero, VpSetSign, and VpSetZero.

Referenced by VpPower(), and VpSqrt().

## ◆ VpNewRbClass()

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

Definition at line 772 of file bigdecimal.c.

References Real::obj, RB_OBJ_FREEZE, RTYPEDDATA_DATA, str, TypedData_Wrap_Struct, and VpAlloc().

Referenced by VpCreateRbObject().

## ◆ VpNumOfChars()

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

Definition at line 4097 of file bigdecimal.c.

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

## ◆ VpOne()

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

Definition at line 4169 of file bigdecimal.c.

## ◆ VpPower()

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

Definition at line 6609 of file bigdecimal.c.

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

## ◆ VpSetPrecLimit()

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

Definition at line 3841 of file bigdecimal.c.

References rmpd_set_thread_local_precision_limit, and VpGetPrecLimit().

## ◆ VpSetRoundMode()

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

Definition at line 3894 of file bigdecimal.c.

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

## ◆ VpSqrt()

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

Definition at line 6180 of file bigdecimal.c.

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

## ◆ VpSzMantissa()

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

Definition at line 5628 of file bigdecimal.c.

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

## ◆ VpToFString()

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

Definition at line 5758 of file bigdecimal.c.

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

## ◆ VpToSpecialString()

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

Definition at line 5675 of file bigdecimal.c.

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

Referenced by VpToFString(), and VpToString().

## ◆ VpToString()

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

Definition at line 5710 of file bigdecimal.c.

References BASE1, BASE_FIG, BDIGIT, BIGDECIMAL_NEGATIVE_P, Real::exponent, Real::frac, Real::Prec, PRIdSIZE, strlen(), and VpToSpecialString().

## ◆ VpVtoD()

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

Definition at line 5984 of file bigdecimal.c.

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

Referenced by VpSqrt().

## Variable Documentation

## ◆ gOne_ABCED9B4_CE73__00400511F31D

volatile const double gOne_ABCED9B4_CE73__00400511F31D = 1.0

Definition at line 3912 of file bigdecimal.c.

## ◆ rb_cBigDecimal

VALUE rb_cBigDecimal

Definition at line 45 of file bigdecimal.c.

Referenced by Init_bigdecimal(), and VpCreateRbObject().

## ◆ rb_mBigMath

VALUE rb_mBigMath

Definition at line 46 of file bigdecimal.c.

Referenced by Init_bigdecimal().