/*
* call-seq:
* fix - numeric => numeric_result
*
* Performs subtraction: the class of the resulting object depends on
* the class of <code>numeric</code> and on the magnitude of the
* result.
*/
static VALUE
fix_minus(VALUE x, VALUE 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;
}
switch (TYPE(y)) {
case T_BIGNUM:
x = rb_int2big(FIX2LONG(x));
return rb_big_minus(x, y);
case T_FLOAT:
return DOUBLE2NUM((double)FIX2LONG(x) - RFLOAT_VALUE(y));
default:
return rb_num_coerce_bin(x, y, '-');
}
}