negative zero or negative nth roots are not handled.legacy
| @@ -590,6 +590,23 @@ real cbrt(real const &x) | |||||
| return ret; | return ret; | ||||
| } | } | ||||
| real pow(real const &x, real const &y) | |||||
| { | |||||
| if (!y) | |||||
| return real::R_1; | |||||
| if (!x) | |||||
| return real::R_0; | |||||
| if (x > real::R_0) | |||||
| return exp(y * log(x)); | |||||
| else /* x < 0 */ | |||||
| { | |||||
| if (y == round(y)) | |||||
| return -exp(y * log(-x)); | |||||
| /* FIXME: negative nth root */ | |||||
| return real::R_0; | |||||
| } | |||||
| } | |||||
| real fabs(real const &x) | real fabs(real const &x) | ||||
| { | { | ||||
| real ret = x; | real ret = x; | ||||
| @@ -1012,6 +1029,14 @@ real atan(real const &x) | |||||
| return ret; | return ret; | ||||
| } | } | ||||
| void real::hexprint() const | |||||
| { | |||||
| printf("%08x", m_signexp); | |||||
| for (int i = 0; i < BIGITS; i++) | |||||
| printf(" %08x", m_mantissa[i]); | |||||
| printf("\n"); | |||||
| } | |||||
| void real::print(int ndigits) const | void real::print(int ndigits) const | ||||
| { | { | ||||
| real x = *this; | real x = *this; | ||||
| @@ -85,7 +85,7 @@ public: | |||||
| friend real re(real const &x); | friend real re(real const &x); | ||||
| friend real sqrt(real const &x); | friend real sqrt(real const &x); | ||||
| friend real cbrt(real const &x); | friend real cbrt(real const &x); | ||||
| /* FIXME: pow */ | |||||
| friend real pow(real const &x, real const &y); | |||||
| /* Rounding, absolute value, remainder etc. */ | /* Rounding, absolute value, remainder etc. */ | ||||
| friend real ceil(real const &x); | friend real ceil(real const &x); | ||||
| @@ -95,6 +95,7 @@ public: | |||||
| friend real round(real const &x); | friend real round(real const &x); | ||||
| friend real fmod(real const &x, real const &y); | friend real fmod(real const &x, real const &y); | ||||
| void hexprint() const; | |||||
| void print(int ndigits = 150) const; | void print(int ndigits = 150) const; | ||||
| static real const R_0; | static real const R_0; | ||||