Skip to content
Snippets Groups Projects
Commit eeb110c7 authored by Daniel Simon's avatar Daniel Simon
Browse files

Bugs in MultiPrecision repaired.

parent 29949c0d
No related branches found
No related tags found
No related merge requests found
...@@ -15,15 +15,16 @@ namespace Arithmetics { ...@@ -15,15 +15,16 @@ namespace Arithmetics {
/* CONSTRUCTORS */ /* CONSTRUCTORS */
MultiPrecision::MultiPrecision(){ MultiPrecision::MultiPrecision(){
mpf_init(number); mpf_init (number);
} }
MultiPrecision::MultiPrecision(int precision) { MultiPrecision::MultiPrecision(int i){
mpf_set_default_prec(precision); signed long int sli = i;
mpf_init_set_si (number, sli);
} }
MultiPrecision::MultiPrecision(double d){ MultiPrecision::MultiPrecision(double d){
mpf_init_set_d(number, d); mpf_init_set_d (number, d);
} }
/* OPERATORS IMPLEMENTATION */ /* OPERATORS IMPLEMENTATION */
...@@ -138,6 +139,10 @@ bool MultiPrecision::operator==(const mpf_t &GMPnumber) const{ ...@@ -138,6 +139,10 @@ bool MultiPrecision::operator==(const mpf_t &GMPnumber) const{
/* METHODS */ /* METHODS */
MultiPrecision MultiPrecision::setPrecision(int precision){
mpf_set_default_prec (precision);
}
void MultiPrecision::printMP(){ void MultiPrecision::printMP(){
int precision = mpf_get_default_prec(); int precision = mpf_get_default_prec();
mpf_out_str(stdout, 10, precision, this->number); std::cout <<std::endl; mpf_out_str(stdout, 10, precision, this->number); std::cout <<std::endl;
......
...@@ -22,8 +22,8 @@ public: ...@@ -22,8 +22,8 @@ public:
/* CONSTRUCTORS */ /* CONSTRUCTORS */
MultiPrecision(); // initialize number to 0 MultiPrecision(); // initialize number to 0
explicit MultiPrecision(int precision); // sets the default precision explicit MultiPrecision(int); // assignment of signed long integer
explicit MultiPrecision(double d); // initialize number explicit MultiPrecision(double d); // assignment of double
/// TODO Constructor for Quad /// TODO Constructor for Quad
/* OPERATORS */ /* OPERATORS */
...@@ -54,6 +54,7 @@ public: ...@@ -54,6 +54,7 @@ public:
/* METHODS */ /* METHODS */
void printMP(); void printMP();
static MultiPrecision setPrecision(int); // sets the default precision
/// TODO void printNumber(int digits, ostream& str = std::cout ); /// TODO void printNumber(int digits, ostream& str = std::cout );
/* DESTRUCTOR */ /* DESTRUCTOR */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment