# 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.0: All quiet functions are now thread-safe. The only exception is `mpd_qformat` when used with the “n” format specifier, which requires a call to `localeconv`.

## Quiet Functions

mpd_adjexp | mpd_alloc | mpd_arith_sign
mpd_as_uint128_triple | 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_from_uint128_triple
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 |  |

## Signaling functions

mpd_abs | mpd_abs_uint | mpd_add
mpd_add_i32 | mpd_add_i64 | mpd_add_ssize
mpd_add_u32 | mpd_add_u64 | mpd_add_uint
mpd_addstatus_raise | mpd_and | mpd_canonical
mpd_ceil | mpd_check_nan | mpd_check_nans
mpd_cmp | mpd_compare | mpd_compare_signal
mpd_copy | mpd_copy_abs | mpd_copy_negate
mpd_copy_sign | mpd_dflt_traphandler | mpd_div
mpd_div_i32 | mpd_div_i64 | mpd_div_ssize
mpd_div_u32 | mpd_div_u64 | mpd_div_uint
mpd_divint | mpd_divmod | mpd_exp
mpd_export_u16 | mpd_export_u32 | mpd_finalize
mpd_floor | mpd_fma | mpd_format
mpd_get_i32 | mpd_get_i64 | mpd_get_ssize
mpd_get_u32 | mpd_get_u64 | mpd_get_uint
mpd_import_u16 | mpd_import_u32 | mpd_init
mpd_invert | mpd_invroot | mpd_ln
mpd_log10 | mpd_logb | mpd_max
mpd_max_mag | mpd_maxcoeff | mpd_min
mpd_min_mag | mpd_minus | mpd_mul
mpd_mul_i32 | mpd_mul_i64 | mpd_mul_ssize
mpd_mul_u32 | mpd_mul_u64 | mpd_mul_uint
mpd_new | mpd_next_minus | mpd_next_plus
mpd_next_toward | mpd_or | mpd_plus
mpd_pow | mpd_powmod | mpd_qsset_uint
mpd_quantize | mpd_reduce | mpd_rem
mpd_rem_near | mpd_rescale | mpd_resize
mpd_resize_zero | mpd_rotate | mpd_round_to_int
mpd_round_to_intx | mpd_scaleb | mpd_set_i32
mpd_set_i64 | mpd_set_ssize | mpd_set_string
mpd_set_u32 | mpd_set_u64 | mpd_set_uint
mpd_setminalloc | mpd_shift | mpd_shiftl
mpd_shiftn | mpd_shiftr | mpd_sqrt
mpd_sset_i32 | mpd_sset_i64 | mpd_sset_ssize
mpd_sset_u32 | mpd_sset_u64 | mpd_sub
mpd_sub_i32 | mpd_sub_i64 | mpd_sub_ssize
mpd_sub_u32 | mpd_sub_u64 | mpd_sub_uint
mpd_trunc | mpd_xor |