|
Ruby
2.7.2p137(2020-10-01revision5445e0435260b449decf2ac16f9d09bae3cafe72)
|
#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 (DBL_DIG+1) /* 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 } |
Variables | |
| VALUE | rb_cBigDecimal |
| VALUE | rb_mBigMath |
| volatile const double | gOne_ABCED9B4_CE73__00400511F31D = 1.0 |
| #define BASE RMPD_BASE |
Definition at line 74 of file bigdecimal.c.
| #define BASE1 (BASE/10) |
Definition at line 77 of file bigdecimal.c.
| #define BASE_FIG RMPD_COMPONENT_FIGURES |
Definition at line 73 of file bigdecimal.c.
| #define BIGDECIMAL_NEGATIVE_P | ( | bd | ) | ((bd)->sign < 0) |
Definition at line 131 of file bigdecimal.c.
| #define BIGDECIMAL_POSITIVE_P | ( | bd | ) | ((bd)->sign > 0) |
Definition at line 130 of file bigdecimal.c.
| #define BigMath_exp | ( | x, | |
| n | |||
| ) | BigMath_s_exp(rb_mBigMath, (x), (n)) |
Definition at line 2176 of file bigdecimal.c.
| #define BigMath_log | ( | x, | |
| n | |||
| ) | BigMath_s_log(rb_mBigMath, (x), (n)) |
Definition at line 2177 of file bigdecimal.c.
Definition at line 80 of file bigdecimal.c.
| #define DoSomeOne | ( | x, | |
| y, | |||
| f | |||
| ) | rb_num_coerce_bin(x,y,f) |
Definition at line 136 of file bigdecimal.c.
| #define ENTER | ( | n | ) | volatile VALUE RB_UNUSED_VAR(vStack[n]);int iStack=0 |
Definition at line 68 of file bigdecimal.c.
| #define GUARD_OBJ | ( | p, | |
| y | |||
| ) | ((p)=(y), SAVE(p)) |
Definition at line 71 of file bigdecimal.c.
| #define HALF_BASE (BASE/2) |
Definition at line 76 of file bigdecimal.c.
| #define is_positive | ( | x | ) | (!is_negative(x)) |
Definition at line 2200 of file bigdecimal.c.
| #define maxnr 100UL /* Maximum iterations for calculating sqrt. */ |
Definition at line 3547 of file bigdecimal.c.
| #define MemCmp | ( | x, | |
| y, | |||
| z | |||
| ) | memcmp(x,y,z) |
Definition at line 3551 of file bigdecimal.c.
| #define MUL_OVERFLOW_SIGNED_INTEGER_P | ( | a, | |
| b, | |||
| min, | |||
| max | |||
| ) |
Definition at line 35 of file bigdecimal.c.
| #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.
| #define NDEBUG |
Definition at line 17 of file bigdecimal.c.
| #define PUSH | ( | x | ) | (vStack[iStack++] = (VALUE)(x)) |
Definition at line 69 of file bigdecimal.c.
| #define RB_OBJ_CLASSNAME | ( | obj | ) | rb_obj_class(obj) |
Definition at line 98 of file bigdecimal.c.
Definition at line 99 of file bigdecimal.c.
| #define RMPD_PRECISION_LIMIT_DEFAULT ((size_t)0) |
Definition at line 3660 of file bigdecimal.c.
| #define rmpd_set_thread_local_exception_mode | ( | mode | ) |
Definition at line 3621 of file bigdecimal.c.
| #define rmpd_set_thread_local_precision_limit | ( | limit | ) |
Definition at line 3654 of file bigdecimal.c.
| #define rmpd_set_thread_local_rounding_mode | ( | mode | ) |
Definition at line 3691 of file bigdecimal.c.
| #define RRATIONAL_NEGATIVE_P | ( | x | ) | RTEST(rb_funcall((x), '<', 1, INT2FIX(0))) |
Definition at line 89 of file bigdecimal.c.
| #define RRATIONAL_ZERO_P | ( | x | ) |
Definition at line 84 of file bigdecimal.c.
Definition at line 70 of file bigdecimal.c.
| #define SIGNED_VALUE_MAX INTPTR_MAX |
Definition at line 41 of file bigdecimal.c.
| #define SIGNED_VALUE_MIN INTPTR_MIN |
Definition at line 42 of file bigdecimal.c.
| #define StrCmp | ( | x, | |
| y | |||
| ) | strcmp(x,y) |
Definition at line 3552 of file bigdecimal.c.
| #define VpAllocReal | ( | prec | ) | (Real *)VpMemAlloc(offsetof(Real, frac) + (prec) * sizeof(BDIGIT)) |
Definition at line 660 of file bigdecimal.c.
| #define VpReallocReal | ( | ptr, | |
| prec | |||
| ) | (Real *)VpMemRealloc((ptr), offsetof(Real, frac) + (prec) * sizeof(BDIGIT)) |
Definition at line 661 of file bigdecimal.c.
| enum op_sw |
| Enumerator | |
|---|---|
| OP_SW_ADD | |
| OP_SW_SUB | |
| OP_SW_MULT | |
| OP_SW_DIV | |
Definition at line 3554 of file bigdecimal.c.
Definition at line 3302 of file bigdecimal.c.
References arg.
| NORETURN | ( | static void | cannot_be_coerced_into_BigDecimalVALUE, VALUE | ) |
Definition at line 4052 of file bigdecimal.c.
References i, ISSPACE, len, Real::MaxPrec, NULL, str, strncmp(), 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().
Definition at line 6305 of file bigdecimal.c.
References f, VpAsgn(), and VpMidRound().
Definition at line 4111 of file bigdecimal.c.
References BASE_FIG, buf, exc, i, 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(), v, VpAllocReal, VpCtoV(), VpGetPrecLimit(), and VpSetZero.
Definition at line 4344 of file bigdecimal.c.
References BDIGIT, Real::exponent, Real::frac, Real::MaxPrec, memcpy(), n, Real::Prec, VpGetSign, VpIsInf, VpIsNaN, VpIsZero, VpSetInf, VpSetNaN, and VpSetSign.
Referenced by VpActiveRound(), VpFrac(), VpPower(), and VpSqrt().
Definition at line 5225 of file bigdecimal.c.
References Real::exponent, Real::frac, Real::Prec, printf(), Real::sign, stdout, VpGetSign, VpIsDef, VpIsNaN, and VpIsZero.
Definition at line 655 of file bigdecimal.c.
References rb_cBigDecimal, str, and VpNewRbClass().
| 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 5663 of file bigdecimal.c.
Referenced by VpAlloc().
Definition at line 4972 of file bigdecimal.c.
Definition at line 5887 of file bigdecimal.c.
References BASE, BDIGIT, double, Real::exponent, Real::frac, i, isinf, isnan, Real::MaxPrec, memset(), ne, Real::Prec, SIGNED_VALUE, VpSetNaN, VpSetNegInf, VpSetPosInf, VpSetSign, and VpSetZero.
Referenced by VpSqrt().
Definition at line 3809 of file bigdecimal.c.
Referenced by VpMemAlloc(), VpMemRealloc(), and VpSqrt().
Definition at line 5450 of file bigdecimal.c.
References BASE1, BASE_FIG, Real::exponent, Real::frac, n, and VpHasVal.
Definition at line 6400 of file bigdecimal.c.
References Real::exponent, Real::frac, Real::MaxPrec, Min, Real::Prec, VpAsgn(), VpGetSign, VpHasVal, VpSetSign, and VpSetZero.
Definition at line 3599 of file bigdecimal.c.
Definition at line 3792 of file bigdecimal.c.
Definition at line 3664 of file bigdecimal.c.
References rb_thread_current(), and rb_thread_local_aref().
Referenced by VpAlloc(), and VpSetPrecLimit().
Definition at line 3699 of file bigdecimal.c.
References rb_thread_current(), and rb_thread_local_aref().
Referenced by VpSetRoundMode().
Definition at line 3980 of file bigdecimal.c.
References VpGetDoubleNegZero().
Definition at line 3715 of file bigdecimal.c.
References n, 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().
Definition at line 6290 of file bigdecimal.c.
References BASE_FIG, BDIGIT, f, Real::frac, v, VpExponent, VpHasVal, and VpMidRound().
Definition at line 3575 of file bigdecimal.c.
References memset(), VP_EXCEPTION_MEMORY, VpException(), and xmalloc.
Definition at line 3589 of file bigdecimal.c.
References ptr, VP_EXCEPTION_MEMORY, VpException(), and xrealloc.
Definition at line 6128 of file bigdecimal.c.
References BASE, BASE_FIG, BDIGIT, BIGDECIMAL_NEGATIVE_P, BIGDECIMAL_POSITIVE_P, div(), Real::exponent, f, Real::frac, i, memset(), n, Real::Prec, v, VP_ROUND_CEIL, VP_ROUND_DOWN, VP_ROUND_FLOOR, VP_ROUND_HALF_DOWN, VP_ROUND_HALF_EVEN, VP_ROUND_HALF_UP, VP_ROUND_UP, VpGetSign, and VpSetZero.
Referenced by VpActiveRound(), and VpLeftRound().
Definition at line 4843 of file bigdecimal.c.
References BDIGIT, BDIGIT_DBL, i, and stdout.
Definition at line 644 of file bigdecimal.c.
References klass, obj, and TypedData_Wrap_Struct.
Referenced by VpCreateRbObject().
Definition at line 3936 of file bigdecimal.c.
References BASE_FIG, Real::exponent, NULL, Real::Prec, SIGNED_VALUE, and VpIsDef.
Definition at line 4008 of file bigdecimal.c.
| VP_EXPORT int VpPower | ( | Real * | y, |
| Real * | x, | ||
| SIGNED_VALUE | n | ||
| ) |
Definition at line 6448 of file bigdecimal.c.
References BASE_FIG, BIGDECIMAL_POSITIVE_P, Real::exponent, Real::frac, Real::MaxPrec, n, NULL, Real::Prec, SIGNED_VALUE, VpAlloc(), VpAsgn(), VpDivd(), VpGetSign, VpIsInf, VpIsNaN, VpIsPosInf, VpIsZero, VpMult(), VpSetInf, VpSetNaN, VpSetOne, VpSetSign, and VpSetZero.
Definition at line 3680 of file bigdecimal.c.
References n, rmpd_set_thread_local_precision_limit, and VpGetPrecLimit().
Definition at line 3733 of file bigdecimal.c.
References n, rmpd_set_thread_local_rounding_mode, VpGetRoundMode(), and VpIsRoundMode().
Definition at line 6019 of file bigdecimal.c.
References BASE, BASE_FIG, BIGDECIMAL_NEGATIVE_P, DBLE_FIG, Real::exponent, f, if(), maxnr, Real::MaxPrec, Min, n, NULL, SIGNED_VALUE, sqrt(), VP_EXCEPTION_OP, VpAddSub(), VpAlloc(), VpAsgn(), VpDivd(), VpDtoV(), VpException(), VpIsNaN, VpIsOne, VpIsPosInf, VpIsZero, VpMult(), VpSetNaN, VpSetOne, and VpVtoD().
Definition at line 5467 of file bigdecimal.c.
References BASE1, BDIGIT_DBL, BIGDECIMAL_NEGATIVE_P, Real::frac, i, n, Real::Prec, sprintf(), strlen(), SZ_INF, SZ_NaN, SZ_NINF, VpIsNaN, VpIsNegInf, VpIsPosInf, VpIsPosZero, and VpIsZero.
Definition at line 5597 of file bigdecimal.c.
References BASE, BASE1, BASE_FIG, BDIGIT, BIGDECIMAL_NEGATIVE_P, char, Real::exponent, Real::frac, i, n, Real::Prec, sprintf(), strlen(), and VpToSpecialString().
Definition at line 5514 of file bigdecimal.c.
References sprintf(), SZ_INF, SZ_NaN, SZ_NINF, VpIsNaN, VpIsNegInf, VpIsPosInf, VpIsPosZero, and VpIsZero.
Referenced by VpToFString().
Definition at line 5549 of file bigdecimal.c.
| VP_EXPORT int VpVtoD | ( | double * | d, |
| SIGNED_VALUE * | e, | ||
| Real * | m | ||
| ) |
Definition at line 5823 of file bigdecimal.c.
References BASE, BASE_FIG, DBLE_FIG, div(), double, Real::exponent, f, Real::frac, Min, Real::Prec, printf(), SIGNED_VALUE, stdout, VpGetDoubleNaN(), VpGetDoubleNegInf(), VpGetDoubleNegZero(), VpGetDoublePosInf(), VpGetSign, VpIsNaN, VpIsNegInf, VpIsNegZero, VpIsPosInf, and VpIsPosZero.
Referenced by VpSqrt().
Definition at line 3751 of file bigdecimal.c.
| VALUE rb_cBigDecimal |
Definition at line 45 of file bigdecimal.c.
Referenced by VpCreateRbObject().
| VALUE rb_mBigMath |
Definition at line 46 of file bigdecimal.c.