Skip to content

Instantly share code, notes, and snippets.

@banister
Created June 5, 2012 17:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save banister/3852848b2b42e534908e to your computer and use it in GitHub Desktop.
Save banister/3852848b2b42e534908e to your computer and use it in GitHub Desktop.
static VALUE
flo_mul(VALUE x, VALUE y)
{
switch (TYPE(y)) {
case T_FIXNUM:
return DBL2NUM(RFLOAT_VALUE(x) * (double)FIX2LONG(y));
case T_BIGNUM:
return DBL2NUM(RFLOAT_VALUE(x) * rb_big2dbl(y));
case T_FLOAT:
return DBL2NUM(RFLOAT_VALUE(x) * RFLOAT_VALUE(y));
default:
return rb_num_coerce_bin(x, y, '*');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment