H
Haoqi Haoqi
what's the difference about "LONG2NUM and LONG2FIX" in ruby c api?
why not "return LONG2FIX after FIX2LONG"??
thanks.
ruby source file(numeric.c):
/*
* call-seq:
* fix.abs -> aFixnum
*
* Returns the absolute value of <i>fix</i>.
*
* -12345.abs #=> 12345
* 12345.abs #=> 12345
*
*/
static VALUE
fix_abs(fix)
VALUE fix;
{
long i = FIX2LONG(fix);
if (i < 0) i = -i;
return LONG2NUM(i);
}
why not "return LONG2FIX after FIX2LONG"??
thanks.
ruby source file(numeric.c):
/*
* call-seq:
* fix.abs -> aFixnum
*
* Returns the absolute value of <i>fix</i>.
*
* -12345.abs #=> 12345
* 12345.abs #=> 12345
*
*/
static VALUE
fix_abs(fix)
VALUE fix;
{
long i = FIX2LONG(fix);
if (i < 0) i = -i;
return LONG2NUM(i);
}