Project

General

Profile

Actions

Bug #189

closed

boundary case of acosh() in missing/acosh.c

Added by usa (Usaku NAKAMURA) almost 16 years ago. Updated almost 13 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
Backport:
[ruby-dev:35155]

Description

=begin
こんにちは、なかむら(う)です。

本当にバグなのかどうかよくわかりませんが、missing/acosh.c内の
atanhは、引数が1.0または-1.0の時、Infまたは-Infを返し、かつ、
errnoをセットしません。
C99やSUSv3を見ると、この場合はerrnoにERANGEが設定されるのが正
しい気がしますし、また、test/ruby/test_math.rbのtest_atanhも
そうなることを期待しているように見えます。

というわけで、以下のパッチのように変更すべきなのではないかと
思うのですが、どうでしょうか。

Index: missing/acosh.c

--- missing/acosh.c (revision 17414)
+++ missing/acosh.c (working copy)
@@ -12,6 +12,7 @@
#include <errno.h>
#include <float.h>
#include <math.h>
+#include "ruby.h"

/* DBL_MANT_DIG must be less than 4 times of bits of int */
#ifndef DBL_MANT_DIG
@@ -79,6 +80,14 @@ atanh(double x)
if (z < SMALL_CRITERIA) return x;
z = log(z > 1 ? -1 : (1 + z) / (1 - z)) / 2;
if (neg) z = -z;

  • if (isinf(z))
    +#if defined(ERANGE)
  • errno = ERANGE;
    +#elif defined(EDOM)
  • errno = EDOM;
    +#else
  • ;
    +#endif
    return z;
    }
    #endif

    それでは。
    --
    U.Nakamura
    =end
Actions #1

Updated by matz (Yukihiro Matsumoto) almost 16 years ago

=begin
まつもと ゆきひろです

In message "Re: [ruby-dev:35155] [Bug:trunk] boundary case of acosh() in missing/acosh.c"
on Wed, 18 Jun 2008 20:06:23 +0900, "U.Nakamura" writes:

|本当にバグなのかどうかよくわかりませんが、missing/acosh.c内の
|atanhは、引数が1.0または-1.0の時、Infまたは-Infを返し、かつ、
|errnoをセットしません。
|C99やSUSv3を見ると、この場合はerrnoにERANGEが設定されるのが正
|しい気がしますし、また、test/ruby/test_math.rbのtest_atanhも
|そうなることを期待しているように見えます。
|
|というわけで、以下のパッチのように変更すべきなのではないかと
|思うのですが、どうでしょうか。

コミットしてください。反対があればリバートするということで。

=end

Actions #2

Updated by usa (Usaku NAKAMURA) almost 16 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
Applied in changeset r17425.
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0