public Method

Float.%(p1)

flt % other          float
flt.modulo(other)    float

Return the modulo after division of flt by other.

6543.21.modulo(137)      #=> 104.21
6543.21.modulo(137.24)   #=> 92.9299999999996

Source Code

/*
*  call-seq:
*     flt % other         => float
*     flt.modulo(other)   => float
*  
*  Return the modulo after division of <code>flt</code> by <code>other</code>.
*     
*     6543.21.modulo(137)      #=> 104.21
*     6543.21.modulo(137.24)   #=> 92.9299999999996
*/

static VALUE
flo_mod(x, y)
   VALUE x, y;
{
   double fy, mod;

   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, 0, &mod);
   return rb_float_new(mod);
}
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.