+(p1)
public
Performs addition: the class of the resulting object depends on the class
of numeric and on the magnitude of the result.
Show source
/*
* call-seq:
* fix + numeric => numeric_result
*
* Performs addition: the class of the resulting object depends on
* the class of <code>numeric</code> and on the magnitude of the
* result.
*/
static VALUE
fix_plus(x, y)
VALUE x, y;
{
if (FIXNUM_P(y)) {
long a, b, c;
VALUE r;
a = FIX2LONG(x);
b = FIX2LONG(y);
c = a + b;
r = LONG2NUM(c);
return r;
}
if (TYPE(y) == T_FLOAT) {
return rb_float_new((double)FIX2LONG(x) + RFLOAT(y)->value);
}
return rb_num_coerce_bin(x, y);
}