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

ruby-changes:14842

From: mame <ko1@a...>
Date: Thu, 18 Feb 2010 22:49:11 +0900 (JST)
Subject: [ruby-changes:14842] Ruby:r26707 (trunk): * math.c (math_atanh): raise ERANGE without calling atanh if absolute

mame	2010-02-18 22:39:11 +0900 (Thu, 18 Feb 2010)

  New Revision: 26707

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

  Log:
    * math.c (math_atanh): raise ERANGE without calling atanh if absolute
      value is 1 to achieve platform-independent math.  [ruby-core:28219]
    
    * math.c (math_lgamma): return [Infinity, 1] without calling lgamma_r
      if argument is infinity or -infinity.  [ruby-core:28219]

  Modified files:
    trunk/ChangeLog
    trunk/math.c

Index: math.c
===================================================================
--- math.c	(revision 26706)
+++ math.c	(revision 26707)
@@ -310,6 +310,10 @@
     Need_Float(x);
     errno = 0;
     d0 = RFLOAT_VALUE(x);
+    if (d0 == 1.0 || d0 == -1.0) {
+	errno = ERANGE;
+	rb_sys_fail("atanh");
+    }
     d = atanh(d0);
     domain_check(d0, d, "atanh");
     infinity_check(x, d, "atanh");
@@ -715,6 +719,9 @@
     Need_Float(x);
     errno = 0;
     d0 = RFLOAT_VALUE(x);
+    if (isinf(d0)) {
+	return rb_assoc_new(DBL2NUM(INFINITY), INT2FIX(1));
+    }
     d = lgamma_r(d0, &sign);
     domain_check(d0, d, "lgamma");
     v = DBL2NUM(d);
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 26706)
+++ ChangeLog	(revision 26707)
@@ -1,3 +1,11 @@
+Thu Feb 18 22:31:15 2010  Yusuke Endoh  <mame@t...>
+
+	* math.c (math_atanh): raise ERANGE without calling atanh if absolute
+	  value is 1 to achieve platform-independent math.  [ruby-core:28219]
+
+	* math.c (math_lgamma): return [Infinity, 1] without calling lgamma_r
+	  if argument is infinity or -infinity.  [ruby-core:28219]
+
 Thu Feb 18 22:28:00 2010  Kenta Murata  <mrkn@m...>
 
 	* confiure.in: new --with-ext and --with-out-ext options for extmk.

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

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