|
Boost Users : |
From: chun ping wang (cablepuff_at_[hidden])
Date: 2006-08-09 23:19:25
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_at_[hidden] <james.jones_at_[hidden]>
wrote:
>
> From: "chun ping wang" <cablepuff_at_[hidden]>
> > [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_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net