10#ifndef INCLUDED_BIGFLOAT_H
11#define INCLUDED_BIGFLOAT_H
13#define __GMP_WITHIN_CONFIGURE
17#undef __GMP_WITHIN_CONFIGURE
29 bigfloat(
const unsigned long u) { mpf_init_set_ui(
x, u); }
32 bigfloat(
const float d) { mpf_init_set_d(
x, (
double)d); }
34 bigfloat(
const char *str) { mpf_init_set_str(
x, (
char*)str, 10); }
36 operator double (
void)
const {
return (
double)mpf_get_d(
x); }
38 unsigned long bprec = (
unsigned long)(3.321928094 * (
double)dprec);
39 mpf_set_default_prec(bprec);
43 unsigned long bprec = (
unsigned long)(3.321928094 * (
double)dprec);
44 mpf_set_prec(
x,bprec);
67 mpf_set_d(
x, (
double)y);
94 mpf_add_ui(a.
x,
x.x,y);
100 mpf_sub(a.
x,
x.x,y.
x);
106 mpf_ui_sub(a.
x,
x,y.
x);
112 mpf_sub_ui(a.
x,
x.x,y);
124 mpf_mul(a.
x,
x.x,y.
x);
130 mpf_mul_ui(a.
x,
x.x,y);
136 mpf_div(a.
x,
x.x,y.
x);
142 mpf_ui_div(a.
x,
x,y.
x);
148 mpf_div_ui(a.
x,
x.x,y);
172 mpf_pow_ui(b.
x,a.
x,power);
178 mpfr_pow(b.
x,a.
x,power.
x,GMP_RNDN);
184 mpfr_exp(b.
x,a.
x,GMP_RNDN);
192 test = mpf_cmp(
x.x,y.
x);
193 if (test > 0)
return 1;
199 test = mpf_cmp(
x.x,y.
x);
200 if (test < 0)
return 1;
friend bigfloat operator/(const bigfloat &x, const bigfloat &y)
friend bigfloat operator-(const bigfloat &x, const bigfloat &y)
friend bigfloat operator/(const unsigned long x, const bigfloat &y)
friend bigfloat operator/(const bigfloat &x, const unsigned long y)
bigfloat(const char *str)
friend int operator>(const bigfloat &x, const bigfloat &y)
bigfloat & operator+=(const bigfloat &y)
bigfloat & operator/=(const bigfloat &y)
friend bigfloat operator+(const bigfloat &x, const unsigned long y)
bigfloat & operator*=(const bigfloat &y)
friend bigfloat pow_bf(const bigfloat &a, long power)
bigfloat & operator=(const double y)
friend bigfloat operator-(const bigfloat &x)
friend bigfloat sqrt_bf(const unsigned long x)
bigfloat & operator-=(const bigfloat &y)
friend bigfloat operator-(const bigfloat &x, const unsigned long y)
friend bigfloat exp_bf(const bigfloat &a)
friend bigfloat abs_bf(const bigfloat &x)
void setPrecision(unsigned long dprec)
friend int sgn(const bigfloat &)
bigfloat & operator=(const signed long y)
friend bigfloat operator*(const bigfloat &x, const unsigned long y)
unsigned long getPrecision(void) const
bigfloat & operator=(const bigfloat &y)
friend bigfloat sqrt_bf(const bigfloat &x)
static void setDefaultPrecision(unsigned long dprec)
friend int operator<(const bigfloat &x, const bigfloat &y)
bigfloat(const bigfloat &y)
unsigned long getDefaultPrecision(void) const
friend bigfloat operator-(const unsigned long x, const bigfloat &y)
friend bigfloat operator*(const bigfloat &x, const bigfloat &y)
bigfloat & operator=(const float y)
friend bigfloat pow_bf(const bigfloat &a, bigfloat &power)
friend bigfloat operator+(const bigfloat &x, const bigfloat &y)
bigfloat(const unsigned long u)
bigfloat & operator=(const unsigned long y)