Method: Float#*
- Defined in:
- numeric.c
#*(other) ⇒ Numeric
Returns a new Float which is the product of self and other:
f = 3.14
f * 2 # => 6.28
f * 2.0 # => 6.28
f * Rational(1, 2) # => 1.57
f * Complex(2, 0) # => (6.28+0.0i)
1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 |
# File 'numeric.c', line 1207 VALUE rb_float_mul(VALUE x, VALUE y) { if (FIXNUM_P(y)) { return DBL2NUM(RFLOAT_VALUE(x) * (double)FIX2LONG(y)); } else if (RB_BIGNUM_TYPE_P(y)) { return DBL2NUM(RFLOAT_VALUE(x) * rb_big2dbl(y)); } else if (RB_FLOAT_TYPE_P(y)) { return DBL2NUM(RFLOAT_VALUE(x) * RFLOAT_VALUE(y)); } else { return rb_num_coerce_bin(x, y, '*'); } } |