31 mpf_init_set_ui(x, u);
34 mpf_init_set_si(x, i);
37 mpf_init_set_si(x, (
long)i);
40 mpf_init_set_d(x, (
double)d);
46 mpf_init_set_str(x, (
char *)str, 10);
51 operator const double(
void)
const {
52 return (
double)mpf_get_d(x);
54 static void setDefaultPrecision(
unsigned long dprec) {
55 unsigned long bprec = (
unsigned long)(3.321928094 * (
double)dprec);
56 mpf_set_default_prec(bprec);
59 void setPrecision(
unsigned long dprec) {
60 unsigned long bprec = (
unsigned long)(3.321928094 * (
double)dprec);
61 mpf_set_prec(x, bprec);
64 unsigned long getPrecision(
void)
const {
65 return mpf_get_prec(x);
68 unsigned long getDefaultPrecision(
void)
const {
69 return mpf_get_default_prec();
77 bigfloat &operator=(
const unsigned long y) {
82 bigfloat &operator=(
const signed long y) {
88 mpf_set_d(x, (
double)y);
92 bigfloat &operator=(
const double y) {
103 return *
this = *
this + y;
106 return *
this = *
this - y;
109 return *
this = *
this * y;
112 return *
this = *
this / y;
117 mpf_add(a.x, x.x, y.x);
123 mpf_add_ui(a.x, x.x, y);
129 mpf_sub(a.x, x.x, y.x);
135 mpf_ui_sub(a.x, x, y.x);
141 mpf_sub_ui(a.x, x.x, y);
153 mpf_mul(a.x, x.x, y.x);
159 mpf_mul_ui(a.x, x.x, y);
165 mpf_div(a.x, x.x, y.x);
171 mpf_ui_div(a.x, x, y.x);
177 mpf_div_ui(a.x, x.x, y);
187 friend bigfloat sqrt_bf(
const unsigned long x) {
201 mpf_pow_ui(b.x, a.x, power);
207 mpfr_pow(b.x, a.x, power.x, GMP_RNDN);
213 mpfr_exp(b.x, a.x, GMP_RNDN);
219 mpfr_log(b.x, a.x, GMP_RNDN);
227 test = mpf_cmp(x.x, y.x);
237 test = mpf_cmp(x.x, y.x);