Ruby: ext/bigdecimal/bigdecimal.h File Reference

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

Data Structures | Macros | Functions | Variables
bigdecimal.h File Reference
`#include "ruby/ruby.h"`
`#include <float.h>`

Go to the source code of this file.

## Data Structures
struct | Real

## Macros
#define | RUBY_NO_OLD_COMPATIBILITY
#define | BDIGIT uint16_t
#define | BDIGIT_DBL uint32_t
#define | BDIGIT_DBL_SIGNED int32_t
#define | SIZEOF_BDIGITS 2
#define | PRI_BDIGIT_PREFIX "h"
#define | PRI_BDIGIT_DBL_PREFIX ""
#define | PRIdBDIGIT PRI_BDIGIT_PREFIX"d"
#define | PRIiBDIGIT PRI_BDIGIT_PREFIX"i"
#define | PRIoBDIGIT PRI_BDIGIT_PREFIX"o"
#define | PRIuBDIGIT PRI_BDIGIT_PREFIX"u"
#define | PRIxBDIGIT PRI_BDIGIT_PREFIX"x"
#define | PRIdBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"d"
#define | PRIiBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"i"
#define | PRIoBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"o"
#define | PRIuBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"u"
#define | PRIxBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"x"
#define | FIX_CONST_VALUE_PTR(x) (x)
#define | vabs abs
#define | rb_category_warn(category, ...) rb_warn(__VA_ARGS__)
#define | RMPD_COMPONENT_FIGURES 2
#define | RMPD_BASE ((BDIGIT)100U)
#define | SZ_NaN "NaN"
#define | SZ_INF "Infinity"
#define | SZ_PINF "+Infinity"
#define | SZ_NINF "-Infinity"
#define | VP_EXPORT static
#define | VP_EXCEPTION_ALL ((unsigned short)0x00FF)
#define | VP_EXCEPTION_INFINITY ((unsigned short)0x0001)
#define | VP_EXCEPTION_NaN ((unsigned short)0x0002)
#define | VP_EXCEPTION_UNDERFLOW ((unsigned short)0x0004)
#define | VP_EXCEPTION_OVERFLOW ((unsigned short)0x0001) /* 0x0008) */
#define | VP_EXCEPTION_ZERODIVIDE ((unsigned short)0x0010)
#define | VP_EXCEPTION_OP ((unsigned short)0x0020)
#define | VP_EXCEPTION_MEMORY ((unsigned short)0x0040)
#define | RMPD_EXCEPTION_MODE_DEFAULT 0U
#define | VP_ROUND_MODE ((unsigned short)0x0100)
#define | VP_ROUND_UP 1
#define | VP_ROUND_DOWN 2
#define | VP_ROUND_HALF_UP 3
#define | VP_ROUND_HALF_DOWN 4
#define | VP_ROUND_CEIL 5
#define | VP_ROUND_FLOOR 6
#define | VP_ROUND_HALF_EVEN 7
#define | RMPD_ROUNDING_MODE_DEFAULT VP_ROUND_HALF_UP
#define | VP_SIGN_NaN 0 /* NaN */
#define | VP_SIGN_POSITIVE_ZERO 1 /* Positive zero */
#define | VP_SIGN_NEGATIVE_ZERO -1 /* Negative zero */
#define | VP_SIGN_POSITIVE_FINITE 2 /* Positive finite number */
#define | VP_SIGN_NEGATIVE_FINITE -2 /* Negative finite number */
#define | VP_SIGN_POSITIVE_INFINITE 3 /* Positive infinite number */
#define | VP_SIGN_NEGATIVE_INFINITE -3 /* Negative infinite number */
#define | FLEXIBLE_ARRAY_SIZE /* */
#define | VpBaseFig() rmpd_component_figures()
#define | VpDblFig() rmpd_double_figures()
#define | VpBaseVal() rmpd_base_value()
#define | Abs(a) (((a)>= 0)?(a):(-(a)))
#define | Max(a, b) (((a)>(b))?(a):(b))
#define | Min(a, b) (((a)>(b))?(b):(a))
#define | VpMaxPrec(a) ((a)->MaxPrec)
#define | VpPrec(a) ((a)->Prec)
#define | VpGetFlag(a) ((a)->flag)
#define | VpGetSign(a) (((a)->sign>0)?1:(-1))
#define | VpChangeSign(a, s) {if((s)>0) (a)->sign=(short)Abs((ssize_t)(a)->sign);else (a)->sign=-(short)Abs((ssize_t)(a)->sign);}
#define | VpSetSign(a, s) {if((s)>0) (a)->sign=(short)VP_SIGN_POSITIVE_FINITE;else (a)->sign=(short)VP_SIGN_NEGATIVE_FINITE;}
#define | VpSetOne(a) {(a)->Prec=(a)->exponent=(a)->frac[0]=1;(a)->sign=VP_SIGN_POSITIVE_FINITE;}
#define | VpIsPosZero(a) ((a)->sign==VP_SIGN_POSITIVE_ZERO)
#define | VpIsNegZero(a) ((a)->sign==VP_SIGN_NEGATIVE_ZERO)
#define | VpIsZero(a) (VpIsPosZero(a) || VpIsNegZero(a))
#define | VpSetPosZero(a) ((a)->frac[0]=0,(a)->Prec=1,(a)->sign=VP_SIGN_POSITIVE_ZERO)
#define | VpSetNegZero(a) ((a)->frac[0]=0,(a)->Prec=1,(a)->sign=VP_SIGN_NEGATIVE_ZERO)
#define | VpSetZero(a, s) (void)(((s)>0)?VpSetPosZero(a):VpSetNegZero(a))
#define | VpIsNaN(a) ((a)->sign==VP_SIGN_NaN)
#define | VpSetNaN(a) ((a)->frac[0]=0,(a)->Prec=1,(a)->sign=VP_SIGN_NaN)
#define | VpIsPosInf(a) ((a)->sign==VP_SIGN_POSITIVE_INFINITE)
#define | VpIsNegInf(a) ((a)->sign==VP_SIGN_NEGATIVE_INFINITE)
#define | VpIsInf(a) (VpIsPosInf(a) || VpIsNegInf(a))
#define | VpIsDef(a) ( !(VpIsNaN(a)||VpIsInf(a)) )
#define | VpSetPosInf(a) ((a)->frac[0]=0,(a)->Prec=1,(a)->sign=VP_SIGN_POSITIVE_INFINITE)
#define | VpSetNegInf(a) ((a)->frac[0]=0,(a)->Prec=1,(a)->sign=VP_SIGN_NEGATIVE_INFINITE)
#define | VpSetInf(a, s) (void)(((s)>0)?VpSetPosInf(a):VpSetNegInf(a))
#define | VpHasVal(a) (a->frac[0])
#define | VpIsOne(a) ((a->Prec==1)&&(a->frac[0]==1)&&(a->exponent==1))
#define | VpExponent(a) (a->exponent)

## Functions
VP_EXPORT Real * | VpNewRbClass (size_t mx, char const *str, VALUE klass)
VP_EXPORT Real * | VpCreateRbObject (size_t mx, const char *str)
VP_EXPORT double | VpGetDoubleNaN (void)
VP_EXPORT double | VpGetDoublePosInf (void)
VP_EXPORT double | VpGetDoubleNegInf (void)
VP_EXPORT double | VpGetDoubleNegZero (void)
VP_EXPORT size_t | VpGetPrecLimit (void)
VP_EXPORT size_t | VpSetPrecLimit (size_t n)
VP_EXPORT int | VpIsRoundMode (unsigned short n)
VP_EXPORT unsigned short | VpGetRoundMode (void)
VP_EXPORT unsigned short | VpSetRoundMode (unsigned short n)
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 void * | VpMemAlloc (size_t mb)
VP_EXPORT void * | VpMemRealloc (void *ptr, size_t mb)
VP_EXPORT void | VpFree (Real *pv)
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 | VpActiveRound (Real *y, Real *x, unsigned short f, ssize_t il)
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 void | VpFrac (Real *y, Real *x)
VP_EXPORT int | VpPower (Real *y, Real *x, SIGNED_VALUE n)
VP_EXPORT Real * | VpOne (void)

## Variables
VALUE | rb_cBigDecimal

## Macro Definition Documentation

## ◆ Abs

#define Abs | ( |  | a | ) | (((a)>= 0)?(a):(-(a)))

Definition at line 347 of file bigdecimal.h.

## ◆ BDIGIT

#define BDIGIT uint16_t

Definition at line 48 of file bigdecimal.h.

## ◆ BDIGIT_DBL

#define BDIGIT_DBL uint32_t

Definition at line 49 of file bigdecimal.h.

## ◆ BDIGIT_DBL_SIGNED

#define BDIGIT_DBL_SIGNED int32_t

Definition at line 50 of file bigdecimal.h.

## ◆ FIX_CONST_VALUE_PTR

#define FIX_CONST_VALUE_PTR | ( |  | x | ) | (x)

Definition at line 116 of file bigdecimal.h.

## ◆ FLEXIBLE_ARRAY_SIZE

#define FLEXIBLE_ARRAY_SIZE /* */

Definition at line 235 of file bigdecimal.h.

## ◆ Max

#define Max | ( |  | a,
|  |  | b
| ) |  | (((a)>(b))?(a):(b))

Definition at line 348 of file bigdecimal.h.

## ◆ Min

#define Min | ( |  | a,
|  |  | b
| ) |  | (((a)>(b))?(b):(a))

Definition at line 349 of file bigdecimal.h.

## ◆ PRI_BDIGIT_DBL_PREFIX

#define PRI_BDIGIT_DBL_PREFIX ""

Definition at line 53 of file bigdecimal.h.

## ◆ PRI_BDIGIT_PREFIX

#define PRI_BDIGIT_PREFIX "h"

Definition at line 52 of file bigdecimal.h.

## ◆ PRIdBDIGIT

#define PRIdBDIGIT PRI_BDIGIT_PREFIX"d"

Definition at line 56 of file bigdecimal.h.

## ◆ PRIdBDIGIT_DBL

#define PRIdBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"d"

Definition at line 63 of file bigdecimal.h.

## ◆ PRIiBDIGIT

#define PRIiBDIGIT PRI_BDIGIT_PREFIX"i"

Definition at line 57 of file bigdecimal.h.

## ◆ PRIiBDIGIT_DBL

#define PRIiBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"i"

Definition at line 64 of file bigdecimal.h.

## ◆ PRIoBDIGIT

#define PRIoBDIGIT PRI_BDIGIT_PREFIX"o"

Definition at line 58 of file bigdecimal.h.

## ◆ PRIoBDIGIT_DBL

#define PRIoBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"o"

Definition at line 65 of file bigdecimal.h.

## ◆ PRIuBDIGIT

#define PRIuBDIGIT PRI_BDIGIT_PREFIX"u"

Definition at line 59 of file bigdecimal.h.

## ◆ PRIuBDIGIT_DBL

#define PRIuBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"u"

Definition at line 66 of file bigdecimal.h.

## ◆ PRIxBDIGIT

#define PRIxBDIGIT PRI_BDIGIT_PREFIX"x"

Definition at line 60 of file bigdecimal.h.

## ◆ PRIXBDIGIT

#define PRIXBDIGIT PRI_BDIGIT_PREFIX"X"

Definition at line 61 of file bigdecimal.h.

## ◆ PRIxBDIGIT_DBL

#define PRIxBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"x"

Definition at line 67 of file bigdecimal.h.

## ◆ PRIXBDIGIT_DBL

#define PRIXBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"X"

Definition at line 68 of file bigdecimal.h.

## ◆ rb_category_warn

#define rb_category_warn | ( |  | category,
|  |  | ...
| ) |  | rb_warn(__VA_ARGS__)

Definition at line 163 of file bigdecimal.h.

## ◆ RMPD_BASE

#define RMPD_BASE ((BDIGIT)100U)

Definition at line 182 of file bigdecimal.h.

## ◆ RMPD_COMPONENT_FIGURES

#define RMPD_COMPONENT_FIGURES 2

Definition at line 181 of file bigdecimal.h.

## ◆ RMPD_EXCEPTION_MODE_DEFAULT

#define RMPD_EXCEPTION_MODE_DEFAULT 0U

Definition at line 212 of file bigdecimal.h.

## ◆ RMPD_ROUNDING_MODE_DEFAULT

#define RMPD_ROUNDING_MODE_DEFAULT VP_ROUND_HALF_UP

Definition at line 224 of file bigdecimal.h.

## ◆ RUBY_NO_OLD_COMPATIBILITY

#define RUBY_NO_OLD_COMPATIBILITY

Definition at line 12 of file bigdecimal.h.

## ◆ SIZEOF_BDIGITS

#define SIZEOF_BDIGITS 2

Definition at line 51 of file bigdecimal.h.

## ◆ SZ_INF

#define SZ_INF "Infinity"

Definition at line 190 of file bigdecimal.h.

## ◆ SZ_NaN

#define SZ_NaN "NaN"

Definition at line 189 of file bigdecimal.h.

## ◆ SZ_NINF

#define SZ_NINF "-Infinity"

Definition at line 192 of file bigdecimal.h.

## ◆ SZ_PINF

#define SZ_PINF "+Infinity"

Definition at line 191 of file bigdecimal.h.

## ◆ vabs

#define vabs abs

Definition at line 155 of file bigdecimal.h.

## ◆ VP_EXCEPTION_ALL

#define VP_EXCEPTION_ALL ((unsigned short)0x00FF)

Definition at line 201 of file bigdecimal.h.

## ◆ VP_EXCEPTION_INFINITY

#define VP_EXCEPTION_INFINITY ((unsigned short)0x0001)

Definition at line 202 of file bigdecimal.h.

## ◆ VP_EXCEPTION_MEMORY

#define VP_EXCEPTION_MEMORY ((unsigned short)0x0040)

Definition at line 210 of file bigdecimal.h.

## ◆ VP_EXCEPTION_NaN

#define VP_EXCEPTION_NaN ((unsigned short)0x0002)

Definition at line 203 of file bigdecimal.h.

## ◆ VP_EXCEPTION_OP

#define VP_EXCEPTION_OP ((unsigned short)0x0020)

Definition at line 209 of file bigdecimal.h.

## ◆ VP_EXCEPTION_OVERFLOW

#define VP_EXCEPTION_OVERFLOW ((unsigned short)0x0001) /* 0x0008) */

Definition at line 205 of file bigdecimal.h.

## ◆ VP_EXCEPTION_UNDERFLOW

#define VP_EXCEPTION_UNDERFLOW ((unsigned short)0x0004)

Definition at line 204 of file bigdecimal.h.

## ◆ VP_EXCEPTION_ZERODIVIDE

#define VP_EXCEPTION_ZERODIVIDE ((unsigned short)0x0010)

Definition at line 206 of file bigdecimal.h.

## ◆ VP_EXPORT

#define VP_EXPORT static

Definition at line 198 of file bigdecimal.h.

## ◆ VP_ROUND_CEIL

#define VP_ROUND_CEIL 5

Definition at line 220 of file bigdecimal.h.

## ◆ VP_ROUND_DOWN

#define VP_ROUND_DOWN 2

Definition at line 217 of file bigdecimal.h.

## ◆ VP_ROUND_FLOOR

#define VP_ROUND_FLOOR 6

Definition at line 221 of file bigdecimal.h.

## ◆ VP_ROUND_HALF_DOWN

#define VP_ROUND_HALF_DOWN 4

Definition at line 219 of file bigdecimal.h.

## ◆ VP_ROUND_HALF_EVEN

#define VP_ROUND_HALF_EVEN 7

Definition at line 222 of file bigdecimal.h.

## ◆ VP_ROUND_HALF_UP

#define VP_ROUND_HALF_UP 3

Definition at line 218 of file bigdecimal.h.

## ◆ VP_ROUND_MODE

#define VP_ROUND_MODE ((unsigned short)0x0100)

Definition at line 215 of file bigdecimal.h.

## ◆ VP_ROUND_UP

#define VP_ROUND_UP 1

Definition at line 216 of file bigdecimal.h.

## ◆ VP_SIGN_NaN

#define VP_SIGN_NaN 0 /* NaN */

Definition at line 226 of file bigdecimal.h.

## ◆ VP_SIGN_NEGATIVE_FINITE

#define VP_SIGN_NEGATIVE_FINITE -2 /* Negative finite number */

Definition at line 230 of file bigdecimal.h.

## ◆ VP_SIGN_NEGATIVE_INFINITE

#define VP_SIGN_NEGATIVE_INFINITE -3 /* Negative infinite number */

Definition at line 232 of file bigdecimal.h.

## ◆ VP_SIGN_NEGATIVE_ZERO

#define VP_SIGN_NEGATIVE_ZERO -1 /* Negative zero */

Definition at line 228 of file bigdecimal.h.

## ◆ VP_SIGN_POSITIVE_FINITE

#define VP_SIGN_POSITIVE_FINITE 2 /* Positive finite number */

Definition at line 229 of file bigdecimal.h.

## ◆ VP_SIGN_POSITIVE_INFINITE

#define VP_SIGN_POSITIVE_INFINITE 3 /* Positive infinite number */

Definition at line 231 of file bigdecimal.h.

## ◆ VP_SIGN_POSITIVE_ZERO

#define VP_SIGN_POSITIVE_ZERO 1 /* Positive zero */

Definition at line 227 of file bigdecimal.h.

## ◆ VpBaseFig

#define VpBaseFig | ( |  | ) | rmpd_component_figures()

Definition at line 287 of file bigdecimal.h.

## ◆ VpBaseVal

#define VpBaseVal | ( |  | ) | rmpd_base_value()

Definition at line 289 of file bigdecimal.h.

## ◆ VpChangeSign

#define VpChangeSign | ( |  | a,
|  |  | s
| ) |  | {if((s)>0) (a)->sign=(short)Abs((ssize_t)(a)->sign);else (a)->sign=-(short)Abs((ssize_t)(a)->sign);}

Definition at line 360 of file bigdecimal.h.

## ◆ VpDblFig

#define VpDblFig | ( |  | ) | rmpd_double_figures()

Definition at line 288 of file bigdecimal.h.

## ◆ VpExponent

#define VpExponent | ( |  | a | ) | (a->exponent)

Definition at line 389 of file bigdecimal.h.

## ◆ VpGetFlag

#define VpGetFlag | ( |  | a | ) | ((a)->flag)

Definition at line 353 of file bigdecimal.h.

## ◆ VpGetSign

#define VpGetSign | ( |  | a | ) | (((a)->sign>0)?1:(-1))

Definition at line 358 of file bigdecimal.h.

## ◆ VpHasVal

#define VpHasVal | ( |  | a | ) | (a->frac[0])

Definition at line 387 of file bigdecimal.h.

## ◆ VpIsDef

#define VpIsDef | ( |  | a | ) | ( !(VpIsNaN(a)||VpIsInf(a)) )

Definition at line 383 of file bigdecimal.h.

## ◆ VpIsInf

#define VpIsInf | ( |  | a | ) | (VpIsPosInf(a) || VpIsNegInf(a))

Definition at line 382 of file bigdecimal.h.

## ◆ VpIsNaN

#define VpIsNaN | ( |  | a | ) | ((a)->sign==VP_SIGN_NaN)

Definition at line 376 of file bigdecimal.h.

## ◆ VpIsNegInf

#define VpIsNegInf | ( |  | a | ) | ((a)->sign==VP_SIGN_NEGATIVE_INFINITE)

Definition at line 381 of file bigdecimal.h.

## ◆ VpIsNegZero

#define VpIsNegZero | ( |  | a | ) | ((a)->sign==VP_SIGN_NEGATIVE_ZERO)

Definition at line 369 of file bigdecimal.h.

## ◆ VpIsOne

#define VpIsOne | ( |  | a | ) | ((a->Prec==1)&&(a->frac[0]==1)&&(a->exponent==1))

Definition at line 388 of file bigdecimal.h.

## ◆ VpIsPosInf

#define VpIsPosInf | ( |  | a | ) | ((a)->sign==VP_SIGN_POSITIVE_INFINITE)

Definition at line 380 of file bigdecimal.h.

## ◆ VpIsPosZero

#define VpIsPosZero | ( |  | a | ) | ((a)->sign==VP_SIGN_POSITIVE_ZERO)

Definition at line 368 of file bigdecimal.h.

## ◆ VpIsZero

#define VpIsZero | ( |  | a | ) | (VpIsPosZero(a) || VpIsNegZero(a))

Definition at line 370 of file bigdecimal.h.

## ◆ VpMaxPrec

#define VpMaxPrec | ( |  | a | ) | ((a)->MaxPrec)

Definition at line 351 of file bigdecimal.h.

## ◆ VpPrec

#define VpPrec | ( |  | a | ) | ((a)->Prec)

Definition at line 352 of file bigdecimal.h.

## ◆ VpSetInf

#define VpSetInf | ( |  | a,
|  |  | s
| ) |  | (void)(((s)>0)?VpSetPosInf(a):VpSetNegInf(a))

Definition at line 386 of file bigdecimal.h.

## ◆ VpSetNaN

#define VpSetNaN | ( |  | a | ) | ((a)->frac[0]=0,(a)->Prec=1,(a)->sign=VP_SIGN_NaN)

Definition at line 377 of file bigdecimal.h.

## ◆ VpSetNegInf

#define VpSetNegInf | ( |  | a | ) | ((a)->frac[0]=0,(a)->Prec=1,(a)->sign=VP_SIGN_NEGATIVE_INFINITE)

Definition at line 385 of file bigdecimal.h.

## ◆ VpSetNegZero

#define VpSetNegZero | ( |  | a | ) | ((a)->frac[0]=0,(a)->Prec=1,(a)->sign=VP_SIGN_NEGATIVE_ZERO)

Definition at line 372 of file bigdecimal.h.

## ◆ VpSetOne

#define VpSetOne | ( |  | a | ) | {(a)->Prec=(a)->exponent=(a)->frac[0]=1;(a)->sign=VP_SIGN_POSITIVE_FINITE;}

Definition at line 365 of file bigdecimal.h.

## ◆ VpSetPosInf

#define VpSetPosInf | ( |  | a | ) | ((a)->frac[0]=0,(a)->Prec=1,(a)->sign=VP_SIGN_POSITIVE_INFINITE)

Definition at line 384 of file bigdecimal.h.

## ◆ VpSetPosZero

#define VpSetPosZero | ( |  | a | ) | ((a)->frac[0]=0,(a)->Prec=1,(a)->sign=VP_SIGN_POSITIVE_ZERO)

Definition at line 371 of file bigdecimal.h.

## ◆ VpSetSign

#define VpSetSign | ( |  | a,
|  |  | s
| ) |  | {if((s)>0) (a)->sign=(short)VP_SIGN_POSITIVE_FINITE;else (a)->sign=(short)VP_SIGN_NEGATIVE_FINITE;}

Definition at line 362 of file bigdecimal.h.

## ◆ VpSetZero

#define VpSetZero | ( |  | a,
|  |  | s
| ) |  | (void)(((s)>0)?VpSetPosZero(a):VpSetNegZero(a))

Definition at line 373 of file bigdecimal.h.

## Function Documentation

## ◆ VpActiveRound()

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

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,
|  | char const * | 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

## ◆ rb_cBigDecimal

VALUE rb_cBigDecimal
| extern

Definition at line 45 of file bigdecimal.c.

Referenced by Init_bigdecimal(), and VpCreateRbObject().