ruby-changes:21850
From: naruse <ko1@a...>
Date: Wed, 30 Nov 2011 03:04:10 +0900 (JST)
Subject: [ruby-changes:21850] naruse:r33899 (ruby_1_9_3): merge revision(s) 33198,33199:
naruse 2011-11-30 03:04:00 +0900 (Wed, 30 Nov 2011) New Revision: 33899 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=33899 Log: merge revision(s) 33198,33199: * numeric.c (flo_round): Fix criteria for 32 bits platform part 2 of [bug #5276] * numeric.c (dbl2ival): Fix Float#divmod and #round for 32 bit platform. part 1 of [bug #5276] Modified files: branches/ruby_1_9_3/ChangeLog branches/ruby_1_9_3/numeric.c branches/ruby_1_9_3/version.h Index: ruby_1_9_3/ChangeLog =================================================================== --- ruby_1_9_3/ChangeLog (revision 33898) +++ ruby_1_9_3/ChangeLog (revision 33899) @@ -1,3 +1,13 @@ +Wed Nov 30 02:58:46 2011 Marc-Andre Lafortune <ruby-core@m...> + + * numeric.c (dbl2ival): Fix Float#divmod and #round for 32 bit + platform. part 1 of [bug #5276] + +Wed Nov 30 02:58:46 2011 Marc-Andre Lafortune <ruby-core@m...> + + * numeric.c (flo_round): Fix criteria for 32 bits platform + part 2 of [bug #5276] + Wed Nov 30 02:37:32 2011 Marc-Andre Lafortune <ruby-core@m...> * numeric.c (flo_round): Make Float#round round big values [bug Index: ruby_1_9_3/numeric.c =================================================================== --- ruby_1_9_3/numeric.c (revision 33898) +++ ruby_1_9_3/numeric.c (revision 33899) @@ -873,8 +873,8 @@ static VALUE dbl2ival(double d) { + d = round(d); if (FIXABLE(d)) { - d = round(d); return LONG2FIX((long)d); } return rb_dbl2big(d); @@ -1560,16 +1560,16 @@ 10 ** ((binexp-1)/log_2(10)) <= |number| < 10 ** (binexp/log_2(10)) If binexp >= 0, and since log_2(10) = 3.322259: 10 ** (binexp/4 - 1) < |number| < 10 ** (binexp/3) - binexp/4 <= exp <= binexp/3 + floor(binexp/4) <= exp <= ceil(binexp/3) If binexp <= 0, swap the /4 and the /3 - So if ndigits + binexp/(4 or 3) >= float_dig, the result is number - If ndigits + binexp/(3 or 4) < 0 the result is 0 + So if ndigits + floor(binexp/(4 or 3)) >= float_dig, the result is number + If ndigits + ceil(binexp/(3 or 4)) < 0 the result is 0 */ if (isinf(number) || isnan(number) || - (((long)ndigits - float_dig) * (3 + (binexp > 0)) + binexp >= 0)) { + (ndigits >= float_dig - (binexp > 0 ? binexp / 4 : binexp / 3 - 1))) { return num; } - if ((long)ndigits * (4 - (binexp > 0)) + binexp < 0) { + if (ndigits < - (binexp > 0 ? binexp / 3 + 1 : binexp / 4)) { return DBL2NUM(0); } f = pow(10, ndigits); Index: ruby_1_9_3/version.h =================================================================== --- ruby_1_9_3/version.h (revision 33898) +++ ruby_1_9_3/version.h (revision 33899) @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.3" -#define RUBY_PATCHLEVEL 2 +#define RUBY_PATCHLEVEL 3 #define RUBY_RELEASE_DATE "2011-11-30" #define RUBY_RELEASE_YEAR 2011 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/