hello,
i have a problem with the big int class. i will create binomial coefficient.
my function is
RossiBigInt Binkof ( unsigned long b1, unsigned long b2) { RossiBigInt p1(0), p2(0) ,p3(0), p4(0), erg(0); unsigned int b3; p1=Faku(b1); cout<<"\nn!= "<<p1; p2=Faku(b2); cout<<"\nk!= "<<p2; b3=b1-b2; p3=Faku(b3); p4=p2*p3; cout<<"\nk!*(n-k)!= "<<p4; erg = p1 / p4; cout<<"\nerg= "<<erg; return p1; } or a other version
RossiBigInt Binkof ( unsigned long b1, unsigned long b2) unsigned long b3, b4; RossiBigInt p1(1), p2(0), erg (0); b3= b1-b2; if (b3<b2){b4=b2;} else{b4=b3;b3=b2;} cout <<"\tb4= "<<b4<<" b3= "<<b3; for (unsigned long x=b4+1;x<b1+1;x++){ cout <<"\nx= "<<x; p1=p1 * x; } cout<<"\np1= "<<p1; p2=Faku(b3); cout<<"\np2= "<<p2; erg=p1 /p2; cout<<"\nerg= "<<erg;
return erg; }
the funktion Faku is:
RossiBigInt Faku(unsigned long f) { RossiBigInt erg(1); RossiBigInt t(0); for (int x=0;x<f;x++){ t++; erg=erg*t; } return erg; }
i use Windows XP prof an MSVS2005 prof
and the problem is, that 50 about 20 in first version and 50 about 21 in second verson give the error Vector subscript out of range.
can anybody say my bug.
thankyou amsel
Hi,
C++ BigInt Class: Release 3.0 is availble now at http://sourceforge.net/projects/cpp-bigint/
Log in to post a comment.
hello,
i have a problem with the big int class.
i will create binomial coefficient.
my function is
RossiBigInt Binkof ( unsigned long b1, unsigned long b2)
{
RossiBigInt p1(0), p2(0) ,p3(0), p4(0), erg(0);
unsigned int b3;
p1=Faku(b1); cout<<"\nn!= "<<p1;
p2=Faku(b2); cout<<"\nk!= "<<p2;
b3=b1-b2;
p3=Faku(b3);
p4=p2*p3; cout<<"\nk!*(n-k)!= "<<p4;
erg = p1 / p4; cout<<"\nerg= "<<erg;
return p1;
}
or a other version
RossiBigInt Binkof ( unsigned long b1, unsigned long b2)
unsigned long b3, b4;
RossiBigInt p1(1), p2(0), erg (0);
b3= b1-b2;
if (b3<b2){b4=b2;} else{b4=b3;b3=b2;} cout <<"\tb4= "<<b4<<" b3= "<<b3;
for (unsigned long x=b4+1;x<b1+1;x++){ cout <<"\nx= "<<x;
p1=p1 * x;
} cout<<"\np1= "<<p1;
p2=Faku(b3); cout<<"\np2= "<<p2;
erg=p1 /p2; cout<<"\nerg= "<<erg;
return erg;
}
the funktion Faku is:
RossiBigInt Faku(unsigned long f)
{
RossiBigInt erg(1);
RossiBigInt t(0);
for (int x=0;x<f;x++){
t++;
erg=erg*t;
}
return erg;
}
i use Windows XP prof an MSVS2005 prof
and the problem is, that 50 about 20 in first version and 50 about 21 in second verson give the error Vector subscript out of range.
can anybody say my bug.
thankyou
amsel
Hi,
C++ BigInt Class: Release 3.0 is availble now at http://sourceforge.net/projects/cpp-bigint/