On 30 Aug 2007, at 16:46, Pe?a, Botp wrote:

> i checked divmod second value is same as modulo result (fr which i  
> based my previous statement to not trust float division; of course,  
> i may be wrong). so i reckon, ruby gets modulo first, then generate  
> q by q=(num-r)/div.  Thus ruby can only guarantee num = q*div + r.  
> (maybe modulo is wrong, and the documentation can be wrong too). i  
> think.
>
> i'm sorry. i tend to generalize. i don't read ruby source. correct  
> me if i'm wrong, pls.
>
> kind regards -botp

You are correct I think. In numeric.c, flo_divmod (Float#divmod) and  
flo_mod (Float#%) both call flodivmod which calls fmod to generate  
the modulo and then calculates q as you say.

Alex Gutteridge

Bioinformatics Center
Kyoto University