зеркало из https://github.com/github/ruby.git
* numeric.c: Infinity.numerator returns self. [experimental]
* numeric.c: Infinity.denominator returns 1. [experimental] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21176 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
e12b44e375
Коммит
292d6ee99f
|
@ -1,3 +1,9 @@
|
|||
Mon Dec 29 21:22:31 2008 Tadayoshi Funaba <tadf@dotrb.org>
|
||||
|
||||
* numeric.c: Infinity.numerator returns self. [experimental]
|
||||
|
||||
* numeric.c: Infinity.denominator returns 1. [experimental]
|
||||
|
||||
Mon Dec 29 20:57:14 2008 Yuki Sonoda (Yugui) <yugui@yugui.jp>
|
||||
|
||||
* man/ri.1: new manpage.
|
||||
|
|
20
numeric.c
20
numeric.c
|
@ -1352,6 +1352,23 @@ flo_truncate(VALUE num)
|
|||
return LONG2FIX(val);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
flo_numerator(VALUE num)
|
||||
{
|
||||
double d = RFLOAT_VALUE(num);
|
||||
if (isinf(d) || isnan(d))
|
||||
return num;
|
||||
return rb_call_super(0, 0);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
flo_denominator(VALUE num)
|
||||
{
|
||||
double d = RFLOAT_VALUE(num);
|
||||
if (isinf(d) || isnan(d))
|
||||
return INT2FIX(1);
|
||||
return rb_call_super(0, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
|
@ -3247,6 +3264,9 @@ Init_Numeric(void)
|
|||
rb_define_method(rb_cFloat, "round", flo_round, -1);
|
||||
rb_define_method(rb_cFloat, "truncate", flo_truncate, 0);
|
||||
|
||||
rb_define_method(rb_cFloat, "numerator", flo_numerator, 0);
|
||||
rb_define_method(rb_cFloat, "denominator", flo_denominator, 0);
|
||||
|
||||
rb_define_method(rb_cFloat, "nan?", flo_is_nan_p, 0);
|
||||
rb_define_method(rb_cFloat, "infinite?", flo_is_infinite_p, 0);
|
||||
rb_define_method(rb_cFloat, "finite?", flo_is_finite_p, 0);
|
||||
|
|
Загрузка…
Ссылка в новой задаче