From: "chun ping wang"
[code skipped] T n(Random::randint<T>(numeric_cast<T>(pow(2.0, num_digits - 1)), numeric_cast<T>(pow(2.0, num_digits))) [code skipped]
now num_digits is number of bits. If i pass 160 bit as like for DSA algorithm the program crashes. I pass 8 and it works, how come? Is there a better way to do this? Oh f is any function that can deteremine if a number is most likely a prime or not....
My guess is that numeric_cast<T>(pow(2.0, num_digits)) throws an overflow exception. I don't know what you're using for T, but obviously even a long long can't hold a 160-bit integer (at least not on any architecture I'm aware of). To verify this, catch on overflow_error and see if this prevents the crash. - James Jones Administrative Data Mgmt. Webmaster 375 Raritan Center Pkwy, Suite A Data Architect Edison, NJ 08837