0

I'm having trouble with this arbitrary precision package.

I included "precisioncore.cpp", declared an int_precision, tried to compile and it told me that stdafx.h was missing.

I already read that I can simply omit this include in precisioncore.cpp, and so I did. After that it complained about memcpy not being declared in this scope, so I inlcuded .

The next error I cannot rectify:

\precisioncore.cpp|4222|error: call of overloaded 'int_precision(float_precision&)' is ambiguous|

This is line 4222: r2=(int_precision)rf; r2 being an int_precision and rf being a float_precision. I understand that the float is explicitly casted into an int, but looking into the reference that came with the package this should not be a problem, at least not syntax-wise.

Does anyone here know this package? Any experiences with the same issue, maybe?

EDIT: It looks like the package is working perfectly in Visual Studio. Couldn't figure how to get it working in C:B, though...

Qantas 94 Heavy
  • 14,790
  • 31
  • 61
  • 78
alexander remus
  • 379
  • 1
  • 3
  • 10

1 Answers1

0

ok so... I had the same problem while trying to hook up that library to CodeBlocks under GCC.

It seems to me that *int_precision(float_precision&)* constructor is not declared anywhere in *int_precision* class and that is the reason you are getting that error. So i have no clue how it can be working under Visual studio.

Anyways, my solution was to add that constructor myself:

in iprecision.h file inside *int_precision* class next to the other constructor declarations add:

int_precision( const float_precision& );

then somewhere in precisioncore.cpp file add:

int_precision::int_precision( const float_precision& s )
{//note that behavior is similar to int(double) cast
 //int(9.99) yields 9; and int(-0.9) yields 0;
  if(s.exponent()<0)
      mNumber = ito_precision_string( int(0), true );
      //code taken from int_precision(int) constructor
  else
  {
      mNumber=s.get_mantissa();
      if(mNumber[0]=='-'||mNumber[0]=='+')
          mNumber.resize(s.exponent()+2);// +1.23456E2 = 123
      else
          mNumber.resize(s.exponent()+1);// 1.2345E2 = 123
  }
}

Note that unlike other constructors this one cannot be inlined as it would create a circular header reference between iprecision.h and fprecision.h headers. That's why the implementation must be in .cpp file.

Hope this helps.