1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* numeric.c (num_step): remove epsilon; add margin of 0.5, to make

"1.1.step(1.5,0.1)" to work (third try).


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3764 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2003-05-06 16:48:51 +00:00
parent 3f8d7303c1
commit e49203726e
3 changed files with 7 additions and 5 deletions

View file

@ -1,3 +1,8 @@
Wed May 7 01:21:23 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* numeric.c (num_step): remove epsilon; add margin of 0.5, to make
"1.1.step(1.5,0.1)" to work (third try).
Tue May 6 17:51:54 2003 Minero Aoki <aamine@loveruby.net>
* lib/net/pop.rb: rename method: POP3#mail_size -> n_mails
@ -15,9 +20,6 @@ Tue May 6 14:39:36 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* object.c (rb_obj_methods): list singleton methods if recur
argument is false; list all methods otherwise.
* numeric.c (num_step): double epsilon to make "1.1.step(1.5,0.1)"
to work.
Mon May 5 21:19:25 2003 Koji Arai <jca02266@nifty.ne.jp>
* ext/gdbm/gdbm.c (fgdbm_values_at): new method to replace

View file

@ -197,6 +197,7 @@ main()
for (passive = 0; passive <= 1; passive++) {
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC;
hints.ai_protocol = IPPROTO_TCP;
hints.ai_flags = passive ? AI_PASSIVE : 0;
hints.ai_socktype = SOCK_STREAM;
if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {

View file

@ -905,14 +905,13 @@ num_step(argc, argv, from)
}
}
else if (TYPE(from) == T_FLOAT || TYPE(to) == T_FLOAT || TYPE(step) == T_FLOAT) {
const double epsilon = DBL_EPSILON * 2;
double beg = NUM2DBL(from);
double end = NUM2DBL(to);
double unit = NUM2DBL(step);
double n = (end - beg)/unit;
long i;
n = floor(n + n*epsilon) + 1;
n = n + 0.5;
for (i=0; i<n; i++) {
rb_yield(rb_float_new(i*unit+beg));
}