Method: Float#+

Defined in:
numeric.c

#+(other) ⇒ Numeric

Returns a new Float which is the sum of self and other:

f = 3.14
f + 1                 # => 4.140000000000001
f + 1.0               # => 4.140000000000001
f + Rational(1, 1)    # => 4.140000000000001
f + Complex(1, 0)     # => (4.140000000000001+0i)

Returns:


1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
# File 'numeric.c', line 1146

VALUE
rb_float_plus(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, '+');
    }
}