https://redmine.ruby-lang.org/
https://redmine.ruby-lang.org/favicon.ico?1711330511
2014-10-14T17:30:44Z
Ruby Issue Tracking System
Ruby master - Feature #10378: [PATCH 0/3] It's better (1 + 0i).real? return true
https://redmine.ruby-lang.org/issues/10378?journal_id=49437
2014-10-14T17:30:44Z
gogotanaka (Kazuki Tanaka)
mail@tanakakazuki.com
<ul></ul><p>I can find more useful function <code>f_zero_p </code>.</p>
<pre><code class="c syntaxhl" data-language="c"><span class="k">static</span> <span class="n">VALUE</span>
<span class="nf">nucomp_real_p</span><span class="p">(</span><span class="n">VALUE</span> <span class="n">self</span><span class="p">)</span>
<span class="p">{</span>
<span class="n">get_dat1</span><span class="p">(</span><span class="n">self</span><span class="p">);</span>
<span class="k">return</span> <span class="n">f_zero_p</span><span class="p">(</span><span class="n">dat</span><span class="o">-></span><span class="n">imag</span><span class="p">);</span>
<span class="p">}</span>
</code></pre>
Ruby master - Feature #10378: [PATCH 0/3] It's better (1 + 0i).real? return true
https://redmine.ruby-lang.org/issues/10378?journal_id=49644
2014-10-26T03:22:41Z
gogotanaka (Kazuki Tanaka)
mail@tanakakazuki.com
<ul><li><strong>File</strong> <a href="/attachments/4804">update_NEWS.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/4804/update_NEWS.patch">update_NEWS.patch</a> added</li><li><strong>File</strong> <a href="/attachments/4805">add_tests.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/4805/add_tests.patch">add_tests.patch</a> added</li><li><strong>File</strong> <a href="/attachments/4806">update_Complex#real_.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/4806/update_Complex%23real_.patch">update_Complex#real_.patch</a> added</li></ul><p>There are not any arguments or opinions, I've made patches(implement, test, updating NEWS ) anyway.</p>
<p>Please check it.</p>
<p>Thanks.</p>
Ruby master - Feature #10378: [PATCH 0/3] It's better (1 + 0i).real? return true
https://redmine.ruby-lang.org/issues/10378?journal_id=49646
2014-10-26T04:12:30Z
sawa (Tsuyoshi Sawada)
<ul></ul><p>gogo tanakaさん、</p>
<p>他スレッドでのコメントありがとうございます。</p>
Ruby master - Feature #10378: [PATCH 0/3] It's better (1 + 0i).real? return true
https://redmine.ruby-lang.org/issues/10378?journal_id=49647
2014-10-26T06:29:17Z
gogotanaka (Kazuki Tanaka)
mail@tanakakazuki.com
<ul></ul><p>Tsuyoshi Sawada さん<br>
こんにちは. 22年間誤用しておりました.. お恥ずかしい.</p>
<p>ご指摘をするのも心苦しいと察します、わざわざお伝え頂けるとは本当に嬉しく思います.<br>
お陰さまで苦手な英語を一歩前進させる事が出来ました. ありがとうございました!!</p>
<p>話は変わりますが、Tsuyoshi Sawada さん が面白いアイディアを沢山投稿されて、ステキだと思っています.<br>
実際に実装されるまでは色々考えなければいけない所があるんでしょうが(もちろん僕も偉そうな事は決して言えません)</p>
<p>単純に考えを深めたりアイディアを生むきっかけとして僕自身大変楽しく拝見させて頂いております.</p>
<p>今後ともよろしくお願い致します.</p>
Ruby master - Feature #10378: [PATCH 0/3] It's better (1 + 0i).real? return true
https://redmine.ruby-lang.org/issues/10378?journal_id=49677
2014-10-28T08:39:20Z
t-nissie (Takeshi Nishimatsu)
t_nissie@yahoo.co.jp
<ul></ul><p>Objection.</p>
<p>Especially for Float, Complex(1.0,0.0) and Complex(1.0,-0.0) have meanings:<br>
sqrt[-x+i(+0)]=i<em>sqrt(x)<br>
sqrt[-x+i(-0)]=-i</em>sqrt(x)<br>
So, they are complex. Not real.<br>
And, please see the man page of cproj(3), though cproj is not implemented in Ruby.</p>
<p>Please see Goldberg's review.<br>
<a href="http://docs.oracle.com/cd/E19957-01/806-4847/ncg_goldberg.html" class="external">http://docs.oracle.com/cd/E19957-01/806-4847/ncg_goldberg.html</a> (EUC encoded)<br>
<a href="http://iss.ndl.go.jp/books/R100000039-I001404293-00" class="external">http://iss.ndl.go.jp/books/R100000039-I001404293-00</a><br>
@article{goldberg1991ecs,<br>
title={What every computer scientist should know about floating-point arithmetic},<br>
author={David Goldberg},<br>
journal={ACM Computing Surveys},<br>
volume={23},<br>
number={1},<br>
pages={5--48},<br>
year={1991}}<br>
<a href="http://dl.acm.org/citation.cfm?id=103163" class="external">http://dl.acm.org/citation.cfm?id=103163</a><br>
This good review is also linked from <a href="https://bugs.ruby-lang.org/projects/ruby/wiki/HowToReportJa" class="external">https://bugs.ruby-lang.org/projects/ruby/wiki/HowToReportJa</a> .</p>
<p>BTW, I do not like<br>
-1.0-0.0i => (-1.0+0.0i) ,<br>
though I know that it is translated as<br>
-1.0-0.0i => Complex(-1.0,0.0)-Complex(0.0,-0.0) => (-1.0+0.0i) .</p>
Ruby master - Feature #10378: [PATCH 0/3] It's better (1 + 0i).real? return true
https://redmine.ruby-lang.org/issues/10378?journal_id=49686
2014-10-28T16:22:18Z
gogotanaka (Kazuki Tanaka)
mail@tanakakazuki.com
<ul></ul><p>@Takeshi Nishimatsu san<br>
Thank you for your comments and sharing good article.</p>
<p>From this article, your point-out might be right. I admit <code>Complex(x, 0.0)</code> is not truly real.<br>
And I suppose <code>-1.0-0.0i</code> not be <code>-1.0+0.0i</code> too.</p>
<p>Aside from that, as I said <code>#is_a?(Complex)</code> or current <code>#real?</code> can be the way we check whether a number is truly real or not.<br>
Actually whichever is ok, modifying #real? or implementing as new method.</p>
<p>What I want right now is checking whether a act as real.</p>
<p>So lets run through a few scenarios (I'd better find more practical example... * (</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">c</span> <span class="o">=</span> <span class="p">(</span><span class="mf">2.0</span> <span class="o">+</span> <span class="mf">1.0</span><span class="n">i</span><span class="p">)</span>
<span class="n">a1</span> <span class="o">=</span> <span class="p">(</span><span class="o">-</span><span class="mf">1.0</span><span class="o">+</span><span class="mf">0.0</span><span class="n">i</span><span class="p">)</span>
<span class="nb">p</span> <span class="n">c</span> <span class="o">*</span> <span class="n">a1</span>
<span class="n">a2</span> <span class="o">=</span> <span class="p">(</span><span class="o">-</span><span class="mf">1.0</span><span class="o">-</span><span class="mf">0.0</span><span class="n">i</span><span class="p">)</span>
<span class="nb">p</span> <span class="n">c</span> <span class="o">*</span> <span class="n">a2</span>
<span class="n">a3</span> <span class="o">=</span> <span class="p">(</span><span class="o">-</span><span class="mf">1.0</span><span class="o">+</span><span class="mi">0</span><span class="n">i</span><span class="p">)</span>
<span class="nb">p</span> <span class="n">c</span> <span class="o">*</span> <span class="n">a3</span>
<span class="n">a4</span> <span class="o">=</span> <span class="o">-</span><span class="mf">1.0</span>
<span class="nb">p</span> <span class="n">c</span> <span class="o">*</span> <span class="n">a4</span>
</code></pre>
<p>a1~4 act as same. When I check a5 is also same, I have to write</p>
<pre><code>a5.is_a?(Complex) && a5.imag.zero?
</code></pre>
<p>It's little bit diffuse.</p>
<p>Thanks.</p>
Ruby master - Feature #10378: [PATCH 0/3] It's better (1 + 0i).real? return true
https://redmine.ruby-lang.org/issues/10378?journal_id=49696
2014-10-29T00:49:06Z
t-nissie (Takeshi Nishimatsu)
t_nissie@yahoo.co.jp
<ul></ul><p>FYI, on Julia:</p>
<pre><code>julia> VERSION
v"0.3.1"
julia> Complex(1.0,-0.0)
1.0 - 0.0im
julia> 1.0-0.0im
1.0 - 0.0im
julia> -1.0-0.0im
-1.0 - 0.0im
julia> bool(Complex(1.0,-0.0))
true
julia> bool(Complex(1.0,0.0))
true
julia> bool(Complex(0.0,0.0))
false
julia> bool(Complex(1.0,1.0))
ERROR: InexactError()
in bool at bool.jl:10
</code></pre>
Ruby master - Feature #10378: [PATCH 0/3] It's better (1 + 0i).real? return true
https://redmine.ruby-lang.org/issues/10378?journal_id=49745
2014-10-30T20:49:03Z
gogotanaka (Kazuki Tanaka)
mail@tanakakazuki.com
<ul></ul><p>@Takeshi Nishimatsu san</p>
<p>Thank for info, how do you think about my points?</p>
Ruby master - Feature #10378: [PATCH 0/3] It's better (1 + 0i).real? return true
https://redmine.ruby-lang.org/issues/10378?journal_id=49748
2014-10-31T01:20:57Z
t-nissie (Takeshi Nishimatsu)
t_nissie@yahoo.co.jp
<ul></ul><blockquote>
<p>to know whether a object whose class has Numeric as superclass is equal to real number or not.</p>
</blockquote>
<p>Simplly, <code>a.real? || a.imag.zero?</code> may be enough for me, so far.</p>
<pre><code>irb(main):016:0> a = 2.16
=> 2.16
irb(main):017:0> a.real? || a.imag.zero?
=> true
irb(main):018:0> a = Complex(1.0,-0.0)
=> (1.0-0.0i)
irb(main):019:0> a.real? || a.imag.zero?
=> true
</code></pre>
<p>Sorry, but I cannot find any reason to change the current<br>
definition of <code>Numeric#real?</code> and to define a new method.</p>
Ruby master - Feature #10378: [PATCH 0/3] It's better (1 + 0i).real? return true
https://redmine.ruby-lang.org/issues/10378?journal_id=49819
2014-11-05T21:40:01Z
gogotanaka (Kazuki Tanaka)
mail@tanakakazuki.com
<ul></ul><p>@Takeshi Nishimatsu san</p>
<p>OK, it does make sense. thanks.</p>
Ruby master - Feature #10378: [PATCH 0/3] It's better (1 + 0i).real? return true
https://redmine.ruby-lang.org/issues/10378?journal_id=69367
2018-01-05T21:01:30Z
naruse (Yui NARUSE)
naruse@airemix.jp
<ul><li><strong>Target version</strong> deleted (<del><i>2.2.0</i></del>)</li></ul>
Ruby master - Feature #10378: [PATCH 0/3] It's better (1 + 0i).real? return true
https://redmine.ruby-lang.org/issues/10378?journal_id=92030
2021-05-20T05:30:03Z
mame (Yusuke Endoh)
mame@ruby-lang.org
<ul><li><strong>Related to</strong> <i><a class="issue tracker-1 status-6 priority-4 priority-default closed" href="/issues/17631">Bug #17631</a>: `Numeric#real?` incorrectly returns true for `NaN` and `INFINITY`</i> added</li></ul>