[#28007] [Feature:trunk] optional reverse_lookup argument for IPSocket#{addr,peeraddr} and Socket.getaddrinfo — Nobuyoshi Nakada <nobu@...>
Hi,
Hi,
[#28015] RCR: RUBY_VERSION_INT — Roger Pack <rogerdpack2@...>
Situation:
Roger Pack:
[#28029] [Bug #2709] $VERBOSE, $DEBUG and Kernel#sprintf — Patrik Wenger <redmine@...>
Bug #2709: $VERBOSE, $DEBUG and Kernel#sprintf
[#28036] [Bug #2710] Kernel#load loads a relative path — Brian Ford <redmine@...>
Bug #2710: Kernel#load loads a relative path
[#28037] Floating Point Bug in 1.8.6-p398 — Austin Ziegler <halostatue@...>
Doing some quick testing with multiruby on something, I see that every
> Doing some quick testing with multiruby on something, I see that every
[#28072] [Bug #2715] Optimization to avoid spawning shell in Kernel#system call should check for failure conditions — Tomasz Wegrzanowski <redmine@...>
Bug #2715: Optimization to avoid spawning shell in Kernel#system call should check for failure conditions
[#28077] Re: [ruby-cvs:33755] Ruby:r26540 (trunk): * enum.c (enum_each_entry): new method #each_entry to pack values — "Akinori MUSHA" <knu@...>
At Tue, 2 Feb 2010 17:54:56 +0900 (JST),
[#28100] [Bug #2721] OpenSSL::Random.random_bytes(1) is very slow the first time on Windows — Greg Hazel <redmine@...>
Bug #2721: OpenSSL::Random.random_bytes(1) is very slow the first time on Windows
[#28103] [Bug #2722] gets on a large file takes a very very long time — Greg Hazel <redmine@...>
Bug #2722: gets on a large file takes a very very long time
Hi,
[#28113] [Bug #2723] $: length affects re-require time of already loaded files — Greg Hazel <redmine@...>
Bug #2723: $: length affects re-require time of already loaded files
[#28141] [Bug #2731] FileUtils.copy prints error message in $DEBUG mode when destination doesn't exist — Kornelius Kalnbach <redmine@...>
Bug #2731: FileUtils.copy prints error message in $DEBUG mode when destination doesn't exist
[#28147] [Bug #2737] StringConstant +"string literal" (unspaced) raises exception — Joe Lapp <redmine@...>
Bug #2737: StringConstant +"string literal" (unspaced) raises exception
[#28151] [Bug #2739] ruby 1.8.7 built with pthreads hangs under some circumstances — Joel Ebel <redmine@...>
Bug #2739: ruby 1.8.7 built with pthreads hangs under some circumstances
Issue #2739 has been updated by Lucas Nussbaum.
[#28154] [Bug #2740] Extend const_missing to pass in the nesting — Yehuda Katz <redmine@...>
Bug #2740: Extend const_missing to pass in the nesting
[#28204] [Bug #2756] Issues with Math and Complex behavior on 1.9 — Brian Ford <redmine@...>
Bug #2756: Issues with Math and Complex behavior on 1.9
[#28206] Is Math module a wrapper of libm? — Yusuke ENDOH <mame@...>
Hi matz --
Hi,
Hi,
Hi,
Hi,
Hi,
Hi
Hi!
Hi,
So here's a summary of the changes that Kenta and I propose, followed
Hi,
Hi,
Hi,
Hi,
On 2010/03/02 14:15, Marc-Andre Lafortune wrote:
[#28215] Removing Syck from ruby — Aaron Patterson <aaron@...>
Hello,
> I would like to remove Syck from ruby, and release it as a gem that I
On Thu, Feb 18, 2010 at 11:28:20PM +0900, Jon wrote:
[#28235] [Feature #2759] Regexp /g and /G options — Michael Fellinger <redmine@...>
Feature #2759: Regexp /g and /G options
Issue #2759 has been updated by caleb clausen.
(2010/03/04 14:53), caleb clausen wrote:
On 3/4/10, NARUSE, Yui <naruse@airemix.jp> wrote:
[#28237] [Bug #2760] unable to cross-compile win32.c — Roger Pack <redmine@...>
Bug #2760: unable to cross-compile win32.c
[#28238] weird behaviour of readline on OSX 10.6 — Andrew Eberbach <eberbach@...>
Hi
[#28273] [Feature #2772] Matrix: Calculating determinant using Bareiss algorithm [patch] — Marc-Andre Lafortune <redmine@...>
Feature #2772: Matrix: Calculating determinant using Bareiss algorithm [patch]
[#28281] [Bug:trunk] add explicit constraints for WONTFIX IO bug — Yusuke ENDOH <mame@...>
Hi, all
[#28300] [Bug #2781] crash when gc_mark()ing already free'd locals of cloned scope — "coderrr ." <redmine@...>
Bug #2781: crash when gc_mark()ing already free'd locals of cloned scope
[#28318] [Bug #2784] The formatting options hash passed to the to_yaml methods do nothing. — Anshul Khandelwal <redmine@...>
Bug #2784: The formatting options hash passed to the to_yaml methods do nothing.
[#28329] [ANN] Ruby 1.9.2dev has passed RubySpec! — Yusuke ENDOH <mame@...>
Hi,
Hi,
On Wed, Feb 24, 2010 at 4:41 PM, Yusuke ENDOH <mame@tsg.ne.jp> wrote:
Hi,
[#28355] [ANN] Toward rich diversity of Ruby development. — Urabe Shyouhei <shyouhei@...>
A short announcement: thanks to some helps of GitHub people, I now have
Hi,
Vladimir Sizikov wrote:
[#28365] Indentifying key MRI-on-Windows issues — Jon <jon.forums@...>
In an effort to begin summarizing key MRI-on-Windows open issues I'm starting this thread in hopes that those interested will respond with details on the key MRI issues they feel need resolution for Windows users.
> My key concern is http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-=
On Tue, Mar 16, 2010 at 10:30 AM, Roger Pack <rogerdpack2@gmail.com> wrote:
> JRuby does do encoding support, though it's not complete yet. I think
Hi Roger, Charles,
> > The snippets in
[#28366] [Bug #2823] IRB Crashes When Completing Method Names of BasicObjects — Run Paint Run Run <redmine@...>
Bug #2823: IRB Crashes When Completing Method Names of BasicObjects
[ruby-core:28291] Re: Is Math module a wrapper of libm?
Hi!
I like the direction we're taking.
I've been thinking about a general decision algorithm. It would look like:
Try to come up with a valid mathematical value (including +-inf but
excluding NaN):
- Check all possible values (excluding NaN). If there is exactly one,
you're done.
- If there are many possible values, are they all basically equal
(e.g. -0.0 vs +0.0, or +pi vs -pi for an angle)? If so, then return
the best one.
- If the possible values are +-Infinity, and the input is +-0.0 can
tell you which to pick, then return the right infinity (pole error
case)
- Otherwise return NaN or raise an error.
This algorithm agrees with your proposal that atan2(0,0) should raise
an error. While we're contradicting IEEE, have you thought of
atan2(+-Inf, +-Inf)? I feel it should also be an error, in the same
way that Inf/Inf doesn't return 1!
Here's an incremental patch that modifies the code according to this.
Note that infinity_check was already redundant, so I removed it.
domain_check was also redundant except potentially for some corner
cases. Indeed SUSv3 states that implementations may set the ERANGE
error flag in case of subnormal values. domain_check would raise an
error if this was the case. Since this behavior is platform dependant
(and far from useful), I removed domain_check also.
I included a line so that sqrt(-0.0) = +0.0 instead of -0.0, because I
feel it makes sense and is consistent with pow(-0.0, 0.5) == +0.0, but
I don't think it matters all that much and I definitely won't fight
over it.
The question that remains in my mind: is it better to return NaN or
raise a domain error? Why should 0.0/0.0 == NaN and atan2(0.0, 0.0)
raise an error? I personally would lean towards always returning NaN
instead of raising an error, but I am not confident in this
preference. Or never return NaN? Thoughts?
diff --git a/math.c b/math.c
index 5064d05..77a8757 100644
--- a/math.c
+++ b/math.c
@@ -11,7 +11,6 @@
#include "ruby/ruby.h"
#include <math.h>
-#include <errno.h>
#define numberof(array) (int)(sizeof(array) / sizeof((array)[0]))
@@ -28,45 +27,6 @@ extern VALUE rb_to_float(VALUE val);
#define domain_error(msg) \
rb_raise(rb_eMathDomainError, "Numerical argument is out of
domain - " #msg);
-static void
-domain_check(double x, double y, const char *msg)
-{
- if (errno) {
- if (isinf(y)) return;
- }
- else {
- if (!isnan(y)) return;
- else if (isnan(x)) return;
- else {
-#if defined(EDOM)
- errno = EDOM;
-#else
- errno = ERANGE;
-#endif
- }
- }
- rb_sys_fail(msg);
-}
-
-static void
-infinity_check(VALUE arg, double res, const char *msg)
-{
- while(1) {
- if (errno) {
- rb_sys_fail(msg);
- }
- if (isinf(res) && !isinf(RFLOAT_VALUE(arg))) {
-#if defined(EDOM)
- errno = EDOM;
-#elif defined(ERANGE)
- errno = ERANGE;
-#endif
- continue;
- }
- break;
- }
-}
-
/*
* call-seq:
* Math.atan2(y, x) => float
@@ -95,6 +55,7 @@ math_atan2(VALUE obj, VALUE y, VALUE x)
dx = RFLOAT_VALUE(x);
dy = RFLOAT_VALUE(y);
if (dx == 0.0 && dy == 0.0) domain_error("atan2");
+ if (isinf(dx) && isinf(dy)) domain_error("atan2");
return DBL2NUM(atan2(dy, dx));
}
@@ -159,12 +120,10 @@ math_acos(VALUE obj, VALUE x)
double d0, d;
Need_Float(x);
- errno = 0;
d0 = RFLOAT_VALUE(x);
/* check for domain error */
if (d0 < -1.0 || 1.0 < d0) domain_error("acos");
d = acos(d0);
- domain_check(d0, d, "acos");
return DBL2NUM(d);
}
@@ -181,12 +140,10 @@ math_asin(VALUE obj, VALUE x)
double d0, d;
Need_Float(x);
- errno = 0;
d0 = RFLOAT_VALUE(x);
/* check for domain error */
if (d0 < -1.0 || 1.0 < d0) domain_error("asin");
d = asin(d0);
- domain_check(d0, d, "asin");
return DBL2NUM(d);
}
@@ -286,12 +243,10 @@ math_acosh(VALUE obj, VALUE x)
double d0, d;
Need_Float(x);
- errno = 0;
d0 = RFLOAT_VALUE(x);
/* check for domain error */
if (d0 < 1.0) domain_error("acosh");
d = acosh(d0);
- domain_check(d0, d, "acosh");
return DBL2NUM(d);
}
@@ -322,7 +277,6 @@ math_atanh(VALUE obj, VALUE x)
double d0, d;
Need_Float(x);
- errno = 0;
d0 = RFLOAT_VALUE(x);
/* check for domain error */
if (d0 < -1.0 || +1.0 < d0) domain_error("atanh");
@@ -330,8 +284,6 @@ math_atanh(VALUE obj, VALUE x)
if (d0 == -1.0) return DBL2NUM(-INFINITY);
if (d0 == +1.0) return DBL2NUM(+INFINITY);
d = atanh(d0);
- domain_check(d0, d, "atanh");
- infinity_check(x, d, "atanh");
return DBL2NUM(d);
}
@@ -387,19 +339,16 @@ math_log(int argc, VALUE *argv)
rb_scan_args(argc, argv, "11", &x, &base);
Need_Float(x);
- errno = 0;
d0 = RFLOAT_VALUE(x);
/* check for domain error */
- if (signbit(d0)) domain_error("log");
+ if (d0 < 0.0) domain_error("log");
/* check for pole error */
- if (d0 == +0.0) return DBL2NUM(-INFINITY);
+ if (d0 == 0.0) return DBL2NUM(-INFINITY);
d = log(d0);
if (argc == 2) {
Need_Float(base);
d /= log(RFLOAT_VALUE(base));
}
- domain_check(d0, d, "log");
- infinity_check(x, d, "log");
return DBL2NUM(d);
}
@@ -434,15 +383,12 @@ math_log2(VALUE obj, VALUE x)
double d0, d;
Need_Float(x);
- errno = 0;
d0 = RFLOAT_VALUE(x);
/* check for domain error */
- if (signbit(d0)) domain_error("log2");
+ if (d0 < 0.0) domain_error("log2");
/* check for pole error */
- if (d0 == +0.0) return DBL2NUM(-INFINITY);
+ if (d0 == 0.0) return DBL2NUM(-INFINITY);
d = log2(d0);
- domain_check(d0, d, "log2");
- infinity_check(x, d, "log2");
return DBL2NUM(d);
}
@@ -464,15 +410,12 @@ math_log10(VALUE obj, VALUE x)
double d0, d;
Need_Float(x);
- errno = 0;
d0 = RFLOAT_VALUE(x);
/* check for domain error */
- if (signbit(d0)) domain_error("log10");
+ if (d0 < 0.0) domain_error("log10");
/* check for pole error */
- if (d0 == +0.0) return DBL2NUM(-INFINITY);
+ if (d0 == 0.0) return DBL2NUM(-INFINITY);
d = log10(d0);
- domain_check(d0, d, "log10");
- infinity_check(x, d, "log10");
return DBL2NUM(d);
}
@@ -506,12 +449,11 @@ math_sqrt(VALUE obj, VALUE x)
double d0, d;
Need_Float(x);
- errno = 0;
d0 = RFLOAT_VALUE(x);
/* check for domain error */
- if (signbit(d0)) domain_error("sqrt");
+ if (d0 < 0) domain_error("sqrt");
+ if (d0 == 0) return DBL2NUM(0);
d = sqrt(d0);
- domain_check(d0, d, "sqrt");
return DBL2NUM(d);
}
@@ -718,14 +660,14 @@ math_gamma(VALUE obj, VALUE x)
/* check for domain error */
if (isinf(d0) && signbit(d0)) domain_error("gamma");
fracpart = modf(d0, &intpart);
- if (fracpart == 0.0 &&
- 0 < intpart &&
- intpart - 1 < (double)numberof(fact_table)) {
- return DBL2NUM(fact_table[(int)intpart - 1]);
+ if (fracpart == 0.0) {
+ if (intpart < 0) domain_error("gamma");
+ if (0 < intpart &&
+ intpart - 1 < (double)numberof(fact_table)) {
+ return DBL2NUM(fact_table[(int)intpart - 1]);
+ }
}
- errno = 0;
d = tgamma(d0);
- domain_check(d0, d, "gamma");
return DBL2NUM(d);
}
@@ -748,7 +690,6 @@ math_lgamma(VALUE obj, VALUE x)
int sign=1;
VALUE v;
Need_Float(x);
- errno = 0;
d0 = RFLOAT_VALUE(x);
/* check for domain error */
if (isinf(d0) && signbit(d0)) domain_error("lgamma");
@@ -756,7 +697,6 @@ math_lgamma(VALUE obj, VALUE x)
return rb_assoc_new(DBL2NUM(INFINITY), INT2FIX(1));
}
d = lgamma_r(d0, &sign);
- domain_check(d0, d, "lgamma");
v = DBL2NUM(d);
return rb_assoc_new(v, INT2FIX(sign));
}
diff --git a/test/ruby/test_math.rb b/test/ruby/test_math.rb
index 3963e91..2f654c1 100644
--- a/test/ruby/test_math.rb
+++ b/test/ruby/test_math.rb
@@ -18,6 +18,7 @@ class TestMath < Test::Unit::TestCase
def test_atan2
assert_raise(Math::DomainError) { Math.atan2(0, 0) }
+ assert_raise(Math::DomainError) { Math.atan2(1.0 / 0.0, 1.0 / 0.0) }
check(0, Math.atan2(0, 1))
check(Math::PI / 4, Math.atan2(1, 1))
check(Math::PI / 2, Math.atan2(1, 0))
@@ -131,7 +132,7 @@ class TestMath < Test::Unit::TestCase
check(2, Math.log(100, 10))
assert_equal(1.0/0, Math.log(1.0/0))
assert_nothing_raised { assert_infinity -Math.log(+0.0) }
- assert_raise(Math::DomainError) { Math.log(-0.0) } # TODO:
[ruby-core:28265]
+ assert_nothing_raised { assert_infinity -Math.log(-0.0) }
assert_raise(Math::DomainError) { Math.log(-1.0) }
assert_raise(TypeError) { Math.log(1,nil) }
end
@@ -142,7 +143,7 @@ class TestMath < Test::Unit::TestCase
check(2, Math.log2(4))
assert_equal(1.0/0, Math.log2(1.0/0))
assert_nothing_raised { assert_infinity -Math.log2(+0.0) }
- assert_raise(Math::DomainError) { Math.log2(-0.0) } # TODO:
[ruby-core:28265]
+ assert_nothing_raised { assert_infinity -Math.log2(-0.0) }
assert_raise(Math::DomainError) { Math.log2(-1.0) }
end
@@ -152,7 +153,7 @@ class TestMath < Test::Unit::TestCase
check(2, Math.log10(100))
assert_equal(1.0/0, Math.log10(1.0/0))
assert_nothing_raised { assert_infinity -Math.log10(+0.0) }
- assert_raise(Math::DomainError) { Math.log10(-0.0) } # TODO:
[ruby-core:28265]
+ assert_nothing_raised { assert_infinity -Math.log10(-0.0) }
assert_raise(Math::DomainError) { Math.log10(-1.0) }
end
@@ -161,7 +162,7 @@ class TestMath < Test::Unit::TestCase
check(1, Math.sqrt(1))
check(2, Math.sqrt(4))
assert_equal(1.0/0, Math.sqrt(1.0/0))
- assert_raise(Math::DomainError) { Math.sqrt(-0.0) } # TODO:
[ruby-core:28265]
+ assert_equal("0.0", Math.sqrt(-0.0).to_s) # insure it is +0.0, not -0.0
assert_raise(Math::DomainError) { Math.sqrt(-1.0) }
end