yeah i get this error.  bad numeric conversion: positive overflow Still i need some way to generate a 160 bit integer somehow. ... :(

On 8/9/06, james.jones@firstinvestors.com <james.jones@firstinvestors.com> wrote:
From: "chun ping wang" <cablepuff@gmail.com>
> [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
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users