[前][次][番号順一覧][スレッド一覧]

ruby-changes:37891

From: nobu <ko1@a...>
Date: Sun, 15 Mar 2015 08:35:02 +0900 (JST)
Subject: [ruby-changes:37891] nobu:r49972 (trunk): math.c: more robust

nobu	2015-03-15 08:34:39 +0900 (Sun, 15 Mar 2015)

  New Revision: 49972

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49972

  Log:
    math.c: more robust
    
    * math.c (math_gamma): make more robust against addition/removal.

  Modified files:
    trunk/math.c
Index: math.c
===================================================================
--- math.c	(revision 49971)
+++ math.c	(revision 49972)
@@ -836,12 +836,10 @@ mingw_tgamma(const double d) https://github.com/ruby/ruby/blob/trunk/math.c#L836
  *
  */
 
-#define NFACT_TABLE 23
-
 static VALUE
 math_gamma(VALUE obj, VALUE x)
 {
-    static const double fact_table[NFACT_TABLE] = {
+    static const double fact_table[] = {
         /* fact(0) */ 1.0,
         /* fact(1) */ 1.0,
         /* fact(2) */ 2.0,
@@ -869,6 +867,7 @@ math_gamma(VALUE obj, VALUE x) https://github.com/ruby/ruby/blob/trunk/math.c#L867
          * impossible to represent exactly in IEEE 754 double which have
          * 53bit mantissa. */
     };
+    enum {NFACT_TABLE = numberof(fact_table)};
     double d;
     d = Get_Double(x);
     /* check for domain error */

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]