:

Error building ttmath on Visual Studio 2008 and 2010

Added by: ~kl, 2013 I 20

Added by: ~kl, 2013 I 20

I've been away from Visual Studio and C++ for years...probably a config problem...

I get
error C2039: 'Add' : is not a member of 'ttmath::UInt<0>'
compiling on both VS 2008 and VS 2010..

any Ideas?

Added by: ~t, 2013 I 20

Sample code please.

Added by: ~kl, 2013 I 21

Here's the code

#include "ttmath.h"
#include <string.h>
#include <cstdio>
#include <iomanip>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{

ttmath::Big<0,0> eye;
const ttmath::Big<0,2> two;
ttmath::Big<0,0> arcTan;
ttmath::Big<0,0> arcTanCosine;
ttmath::Big<0,0> holder;

for(int i = 0; i < 256; i++)
{
eye.FromInt(-1 * i);
holder.FromBig(two);
holder.Exp(eye);

arcTan = ttmath::ATan(holder);
arcTanCosine = ttmath::Cos(arcTan);

cout<<arcTan.ToString().c_str()<<endl;

}

return 0;
}

the error goes right to

uint Add(const Int<value_size> & ss2)
{
bool p1_is_sign = IsSign();
bool p2_is_sign = ss2.IsSign();

---> UInt<value_size>::Add(ss2);

return CorrectCarryAfterAdding(p1_is_sign, p2_is_sign);
}

line 224 of ttmathint.h

Added by: ~t, 2013 I 21

> Big<0,0> eye;

There should be at least one, this is a size of an internal buffer, something like:
int mybuffer[size];
The first integer is the size of the exponent and the letter is the size of the mantissa, e.g.: Big<exponent, mantissa>.
By size I mean the number of machine words, so defining:
Big<1, 2> on a 64bit plarform gives:
64 bits for the exponent and 128 bits for the mantissa

> const ttmath::Big<0,2> two;

Here you are defining a const non-initialized object. You probably want:
const ttmath::Big<1,1> two = 2;

> holder.FromBig(two);
> holder.Exp(eye);

This is equal: holder = Exp(eye)
if you want 2^eye change it to:
holder = two;
holder.Pow(eye);

sample:

int main()
{
typedef ttmath::Big<1, 4> Float;

Float eye;
const Float two = 2;
Float arcTan;
Float arcTanCosine;
Float holder;

for(int i = 0; i < 256; i++)
{
eye = -1 * i;

holder = two;
holder.Pow(eye);

arcTan = ttmath::ATan(holder);
arcTanCosine = ttmath::Cos(arcTan);

cout << arcTan << endl;
}

return 0;
}

Added by: ~kl, 2013 I 22

Awesome, thanks for the help....
I don't know what I was thinking :-)