Hi,

At Mon, 16 Sep 2002 19:30:33 +0900,
Tobias Peters wrote:
> This is not the whole story IMHO. You have to take rounding issues in
> account. If ruby rounded the value to full microseconds in the usual way,
> you would see 300000 instead of 299999. The precision of a double is still 
> just enough to discriminate full microseconds in a date (when zero is 
> 1970/1/1 and proper rounding is applied).

Currently rounding isn't applied.

> I don't know for sure, but I suspect that ruby is always rounding down
> dates and times by intention -- otherwise, what would happen to
> 
> Time.utc(1970,12,31,23,59,59,999999) + .9e-6
> 
> Rounding up the microseconds value may also alter everything else in the 
> date, including the year. Would you want that?

Is it correct?  23:59:59.9999999 is next day?

Anyway, following is rounding patch, but why round() doesn't
work on my box?


Index: time.c =================================================================== RCS file: /cvs/ruby/src/ruby/time.c,v retrieving revision 1.68 diff -u -2 -p -r1.68 time.c --- time.c 8 Sep 2002 12:59:07 -0000 1.68 +++ time.c 16 Sep 2002 14:34:19 -0000 @@ -969,5 +969,5 @@ time_plus(time1, time2) } #endif - usec = tobj->tv.tv_usec + (time_t)(d*1e6); + usec = (time_t)(tobj->tv.tv_usec + d*1e6 + 0.5); sec = tobj->tv.tv_sec + (time_t)f; @@ -1016,5 +1016,5 @@ time_minus(time1, time2) } #endif - usec = tobj->tv.tv_usec - (time_t)(d*1e6); + usec = (time_t)(tobj->tv.tv_usec - d*1e6 + 0.5); sec = tobj->tv.tv_sec - (time_t)f; #ifdef NEGATIVE_TIME_T
-- Nobu Nakada