Bonjour Vik,
>> The point of swapping is to a void possibly expensive modulo, but this
>> should be done on absolute values, otherwise it may not achieve its
>> purpose as stated by the comment?
>
> Ah, true. How widespread are these architectures that need this special
> treatment? Is it really worth handling?
Dunno. AFAICR it was with sparc architectures 25 years ago.
Also I do not like much relying on the subtleties of C99 % wrt negative
numbers to have the algorithm work, I'd be much at ease to deal with sign
and special values at the beginning of the function and proceed with
positive numbers afterwards.
>> I'm unsure about gcd(INT_MIN, 0) should error. Possibly 0 would be nicer?
>
>
> What justification for that do you have?
ISTM that the current implementation has:
\forall int4 n, n \neq MIN_INT4, \gcd(n, 0) = 0 ?
In which case applying the same rule for min int seems ok.
--
Fabien Coelho - CRI, MINES ParisTech