Boost logo

Boost :

Subject: Re: [boost] [math] common_factor template parameters
From: John Maddock (boost.regex_at_[hidden])
Date: 2010-06-26 12:22:12


>static_gcc and static_lcm have unsigned long parameters.
>
>template < unsigned long Value1, unsigned long Value2 >
>struct boost::math::static_gcd;
>
>Could these be changed to uintmax_t?

I would think so yes.

>Is there any deep reason to don't define them for singed integers
>(intmax_t) also?

No, since the result for both functions is always taken as positive for one
or more negative arguments. However.... unless we change the interface,
it's hard to see how to accomplish this easily? Particularly as the
unsigned version has a greater range?

Note that if the arguments might be negative then you could just write:

static_lcm<(arg1 < 0 ? -arg1 : arg1), (arg2 < 0 ? -arg2 : arg2)>::value

to achieve the same effect.

HTH, John.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk