ruby-changes:12363
From: nobu <ko1@a...>
Date: Mon, 13 Jul 2009 01:19:06 +0900 (JST)
Subject: [ruby-changes:12363] Ruby:r24059 (ruby_1_8): * time.c (time_timeval): rounds subsecond toward zero.
nobu 2009-07-13 01:18:51 +0900 (Mon, 13 Jul 2009) New Revision: 24059 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=24059 Log: * time.c (time_timeval): rounds subsecond toward zero. Modified files: branches/ruby_1_8/ChangeLog branches/ruby_1_8/time.c branches/ruby_1_8/version.h Index: ruby_1_8/time.c =================================================================== --- ruby_1_8/time.c (revision 24058) +++ ruby_1_8/time.c (revision 24059) @@ -192,22 +192,17 @@ double f, d; d = modf(RFLOAT(time)->value, &f); - if (d < 0) { - d += 1; - f -= 1; - } + if (d >= 0) { + t.tv_usec = (int)(d*1e6+0.5); + } + else if ((t.tv_usec = (int)(-d*1e6+0.5)) > 0) { + t.tv_usec = 1000000 - t.tv_usec; + f -= 1; + } t.tv_sec = (time_t)f; if (f != t.tv_sec) { rb_raise(rb_eRangeError, "%f out of Time range", RFLOAT(time)->value); } - t.tv_usec = (int)(d*1e6+0.5); - if (t.tv_usec >= 1000000) { - t.tv_usec -= 1000000; - if (++t.tv_sec <= 0) { - --t.tv_sec; - t.tv_usec = 999999; - } - } } break; Index: ruby_1_8/ChangeLog =================================================================== --- ruby_1_8/ChangeLog (revision 24058) +++ ruby_1_8/ChangeLog (revision 24059) @@ -1,3 +1,7 @@ +Mon Jul 13 01:18:46 2009 Nobuyoshi Nakada <nobu@r...> + + * time.c (time_timeval): rounds subsecond toward zero. + Fri Jul 3 06:19:58 2009 Yukihiro Matsumoto <matz@r...> * lib/complex.rb (Numeric#arg): should return NaN for NaN. Index: ruby_1_8/version.h =================================================================== --- ruby_1_8/version.h (revision 24058) +++ ruby_1_8/version.h (revision 24059) @@ -1,7 +1,7 @@ #define RUBY_VERSION "1.8.8" -#define RUBY_RELEASE_DATE "2009-07-03" +#define RUBY_RELEASE_DATE "2009-07-13" #define RUBY_VERSION_CODE 188 -#define RUBY_RELEASE_CODE 20090703 +#define RUBY_RELEASE_CODE 20090713 #define RUBY_PATCHLEVEL -1 #define RUBY_VERSION_MAJOR 1 @@ -9,7 +9,7 @@ #define RUBY_VERSION_TEENY 8 #define RUBY_RELEASE_YEAR 2009 #define RUBY_RELEASE_MONTH 7 -#define RUBY_RELEASE_DAY 3 +#define RUBY_RELEASE_DAY 13 #ifdef RUBY_EXTERN RUBY_EXTERN const char ruby_version[]; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/