* time.c (quo): return an integer if possible.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23928 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2cb0c38014
commit
36b84733f4
@ -1,3 +1,7 @@
|
|||||||
|
Thu Jul 2 05:15:54 2009 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* time.c (quo): return an integer if possible.
|
||||||
|
|
||||||
Wed Jul 1 21:09:25 2009 Tanaka Akira <akr@fsij.org>
|
Wed Jul 1 21:09:25 2009 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* include/ruby/intern.h (rb_time_num_new): declared.
|
* include/ruby/intern.h (rb_time_num_new): declared.
|
||||||
|
13
time.c
13
time.c
@ -112,13 +112,24 @@ static ID id_eq, id_ne, id_quo, id_div, id_cmp, id_lshift;
|
|||||||
#define add(x,y) (rb_funcall((x), '+', 1, (y)))
|
#define add(x,y) (rb_funcall((x), '+', 1, (y)))
|
||||||
#define sub(x,y) (rb_funcall((x), '-', 1, (y)))
|
#define sub(x,y) (rb_funcall((x), '-', 1, (y)))
|
||||||
#define mul(x,y) (rb_funcall((x), '*', 1, (y)))
|
#define mul(x,y) (rb_funcall((x), '*', 1, (y)))
|
||||||
#define quo(x,y) (rb_funcall((x), id_quo, 1, (y)))
|
|
||||||
#define div(x,y) (rb_funcall((x), id_div, 1, (y)))
|
#define div(x,y) (rb_funcall((x), id_div, 1, (y)))
|
||||||
#define mod(x,y) (rb_funcall((x), '%', 1, (y)))
|
#define mod(x,y) (rb_funcall((x), '%', 1, (y)))
|
||||||
#define neg(x) (sub(INT2FIX(0), (x)))
|
#define neg(x) (sub(INT2FIX(0), (x)))
|
||||||
#define cmp(x,y) (rb_funcall((x), id_cmp, 1, (y)))
|
#define cmp(x,y) (rb_funcall((x), id_cmp, 1, (y)))
|
||||||
#define lshift(x,y) (rb_funcall((x), id_lshift, 1, (y)))
|
#define lshift(x,y) (rb_funcall((x), id_lshift, 1, (y)))
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
quo(VALUE x, VALUE y)
|
||||||
|
{
|
||||||
|
VALUE ret;
|
||||||
|
ret = rb_funcall((x), id_quo, 1, (y));
|
||||||
|
if (TYPE(ret) == T_RATIONAL &&
|
||||||
|
((struct RRational *)ret)->den == INT2FIX(1)) {
|
||||||
|
ret = ((struct RRational *)ret)->num;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
divmodv(VALUE n, VALUE d, VALUE *q, VALUE *r)
|
divmodv(VALUE n, VALUE d, VALUE *q, VALUE *r)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user