From: Beman Dawes (bdawes_at_[hidden])
Date: 2001-01-14 09:54:32
At 08:50 PM 1/13/2001 +0000, Paul Moore wrote:
>On 12 Jan 2001, at 20:25, Stephen Silver wrote:
>> But then someone will use a value that doesn't fit in a long (e.g., an
>> unsigned long, or a larger non-standard type) and it will be converted
>> to an int (or a long), with the wrong result. I think all types that
>> are implicitly convertible to IntType ought to be implicitly
>> to rational<IntType> as a matter of principle, and a template is the
>> only way to do that.
>In practical terms, I can't imagine a program using two different
>"integer-like" user defined types which are interconvertible. So in a
>real program, the only types which exist which are likely to be
>convertible to IntType are the builtin ones. Excluding such things
>as long long (not universally supported) and non-standard types
>like _int64, a conversion from long should cover it.
>Or should it? What about unsigned long? This may actually be
>more of a can of worms than it seems at first glance...
Use boost::uintmax_t (from <boost/cstdint.hpp>) if what you want is the
largest unsigned integer type the implementation will support.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk