Ejemplo n.º 1
0
void
mpd_set_u64(mpd_t *result, uint64_t a, mpd_context_t *ctx)
{
	uint32_t status = 0;
	mpd_qset_u64(result, a, ctx, &status);
	mpd_addstatus_raise(ctx, status);
}
Ejemplo n.º 2
0
static void dec128_to_mpd_conv(mpd_context_t * ctx, mpd_t *result, const uint64_t significand_low, const int64_t significand_high, const int64_t exponent_part){
  uint32_t status = 0;
  mpd_t *ten, *sig1, *sig2, *stemp, *sig, *s64, *exp_pow, *exp_partmpd;
  ten = mpd_qnew();
  s64 = mpd_qnew();
  sig1 = mpd_qnew();
  sig2 = mpd_qnew();
  stemp = mpd_qnew();
  sig = mpd_qnew();
  exp_pow = mpd_qnew();
  exp_partmpd = mpd_qnew();
  mpd_qset_i64(ten,10LL,ctx,&status);
  /* 2^64 */
  mpd_qset_string(s64,"18446744073709551616",ctx,&status);
  mpd_qset_u64(sig1,significand_low,ctx,&status);
  mpd_qset_i64(sig2,significand_high,ctx,&status);
  mpd_qmul(stemp,sig2,s64,ctx,&status);
  mpd_qadd(sig,stemp,sig1,ctx,&status);
  mpd_qset_i64(exp_partmpd,exponent_part,ctx,&status);
  mpd_qpow(exp_pow,ten,exp_partmpd,ctx,&status);
  mpd_qmul(result,sig,exp_pow,ctx,&status);
  mpd_del(ten);
  mpd_del(sig1);
  mpd_del(sig2);
  mpd_del(sig);
  mpd_del(stemp);
  mpd_del(s64);
  mpd_del(exp_pow);
  mpd_del(exp_partmpd);
}