public Method

Float.divmod(p1)

flt.divmod(numeric)     array

See Numeric#divmod.

Source Code

/*
*  call-seq:
*     flt.divmod(numeric)    => array
*  
*  See <code>Numeric#divmod</code>.
*/

static VALUE
flo_divmod(x, y)
   VALUE x, y;
{
   double fy, div, mod, val;
   volatile VALUE a, b;

   switch (TYPE(y)) {
     case T_FIXNUM:
       fy = (double)FIX2LONG(y);
       break;
     case T_BIGNUM:
       fy = rb_big2dbl(y);
       break;
     case T_FLOAT:
       fy = RFLOAT(y)->value;
       break;
     default:
       return rb_num_coerce_bin(x, y);
   }
   flodivmod(RFLOAT(x)->value, fy, &div, &mod);
   if (FIXABLE(div)) {
       val = div;
       a = LONG2FIX(val);
   }
   else {
       a = rb_dbl2big(div);
   }
   b = rb_float_new(mod);
   return rb_assoc_new(a, b);
}
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.