Function Index

Naming Conventions

Most functions are specified as signaling functions, which call the trap handler if a trap-enabled condition occurs. This behavior is not always desirable. For example, if temporary storage has been allocated and an error occurs, it is better to free the storage first and raise the condition at function exit. Another example is a threaded application where many functions use the same context simultaneously.

For each signaling function in the specification, libmpdec offers a quiet, thread-safe counterpart. The naming convention is such that if the signaling function is called mpd_add, the quiet function is called mpd_qadd.

All signaling functions are wrappers around quiet functions:

void mpd_qmul(mpd_t *result, const mpd_t *a, const mpd_t *b,
              const mpd_context_t *ctx, uint32_t *status);

void
mpd_mul(mpd_t *result, const mpd_t *a, const mpd_t *b, mpd_context_t *ctx)
{
        uint32_t status = 0;
        mpd_qmul(result, a, b, ctx, &status);
        mpd_addstatus_raise(ctx, status);
}

Instead of writing to the context, mpd_qmul only updates the status parameter. mpd_addstatus_raise adds the accumulated status to the context and calls the trap handler if necessary.

For brevity’s sake, throughout this document only the quiet versions of functions will be explained.

Thread Safety

Changed in version 2.4: All quiet functions are now thread-safe.

Quiet Functions

mpd_adjexp mpd_alloc mpd_arith_sign
mpd_basiccontext mpd_calloc mpd_class
mpd_clear_flags mpd_cmp_total mpd_cmp_total_mag
mpd_compare_total mpd_compare_total_mag mpd_copy_flags
mpd_defaultcontext mpd_del mpd_digits_to_size
mpd_etiny mpd_etop mpd_exp_digits
mpd_fprint mpd_getclamp mpd_getcr
mpd_getemax mpd_getemin mpd_getprec
mpd_getround mpd_getstatus mpd_gettraps
mpd_ieee_context mpd_iscanonical mpd_isconst_data
mpd_isdynamic mpd_isdynamic_data mpd_iseven
mpd_isfinite mpd_isinfinite mpd_isinteger
mpd_isnan mpd_isnegative mpd_isnormal
mpd_isodd mpd_isoddcoeff mpd_isoddword
mpd_ispositive mpd_isqnan mpd_isshared_data
mpd_issigned mpd_issnan mpd_isspecial
mpd_isstatic mpd_isstatic_data mpd_issubnormal
mpd_iszero mpd_iszerocoeff mpd_lsd
mpd_lsnprint_flags mpd_lsnprint_signals mpd_maxcontext
mpd_minalloc mpd_msd mpd_msword
mpd_print mpd_qabs mpd_qabs_uint
mpd_qadd mpd_qadd_i32 mpd_qadd_i64
mpd_qadd_ssize mpd_qadd_u32 mpd_qadd_u64
mpd_qadd_uint mpd_qand mpd_qceil
mpd_qcheck_nan mpd_qcheck_nans mpd_qcmp
mpd_qcompare mpd_qcompare_signal mpd_qcopy
mpd_qcopy_abs mpd_qcopy_negate mpd_qcopy_sign
mpd_qdiv mpd_qdiv_i32 mpd_qdiv_i64
mpd_qdiv_ssize mpd_qdiv_u32 mpd_qdiv_u64
mpd_qdiv_uint mpd_qdivint mpd_qdivmod
mpd_qexp mpd_qexport_u16 mpd_qexport_u32
mpd_qfinalize mpd_qfloor mpd_qfma
mpd_qformat mpd_qget_i32 mpd_qget_i64
mpd_qget_ssize mpd_qget_u32 mpd_qget_u64
mpd_qget_uint mpd_qimport_u16 mpd_qimport_u32
mpd_qinvert mpd_qinvroot mpd_qln
mpd_qlog10 mpd_qlogb mpd_qmax
mpd_qmax_mag mpd_qmaxcoeff mpd_qmin
mpd_qmin_mag mpd_qminus mpd_qmul
mpd_qmul_i32 mpd_qmul_i64 mpd_qmul_ssize
mpd_qmul_u32 mpd_qmul_u64 mpd_qmul_uint
mpd_qncopy mpd_qnew mpd_qnew_size
mpd_qnext_minus mpd_qnext_plus mpd_qnext_toward
mpd_qor mpd_qplus mpd_qpow
mpd_qpowmod mpd_qquantize mpd_qreduce
mpd_qrem mpd_qrem_near mpd_qrescale
mpd_qresize mpd_qresize_zero mpd_qrotate
mpd_qround_to_int mpd_qround_to_intx mpd_qscaleb
mpd_qset_i32 mpd_qset_i64 mpd_qset_i64_exact
mpd_qset_ssize mpd_qset_string mpd_qset_string_exact
mpd_qset_u32 mpd_qset_u64 mpd_qset_u64_exact
mpd_qset_uint mpd_qsetclamp mpd_qsetcr
mpd_qsetemax mpd_qsetemin mpd_qsetprec
mpd_qsetround mpd_qsetstatus mpd_qsettraps
mpd_qshift mpd_qshiftl mpd_qshiftn
mpd_qshiftr mpd_qshiftr_inplace mpd_qsqrt
mpd_qsset_i32 mpd_qsset_i64 mpd_qsset_ssize
mpd_qsset_u32 mpd_qsset_u64 mpd_qsset_uint
mpd_qsub mpd_qsub_i32 mpd_qsub_i64
mpd_qsub_ssize mpd_qsub_u32 mpd_qsub_u64
mpd_qsub_uint mpd_qtrunc mpd_qxor
mpd_radix mpd_realloc mpd_same_quantum
mpd_set_const_data mpd_set_dynamic mpd_set_dynamic_data
mpd_set_flags mpd_set_infinity mpd_set_negative
mpd_set_positive mpd_set_qnan mpd_set_shared_data
mpd_set_sign mpd_set_snan mpd_set_static
mpd_set_static_data mpd_setdigits mpd_seterror
mpd_setspecial mpd_sh_alloc mpd_sign
mpd_signcpy mpd_sizeinbase mpd_snprint_flags
mpd_to_eng mpd_to_eng_size mpd_to_sci
mpd_to_sci_size mpd_trail_zeros mpd_version
mpd_word_digits mpd_zerocoeff