* [ruby-core:65680] [ruby-trunk - Feature #10378] [Open] [PATCH 0/3] It's better (1 + 0i).real? return true
[not found] <redmine.issue-10378.20141013195156@ruby-lang.org>
@ 2014-10-13 19:51 ` mail
2014-10-14 17:30 ` [ruby-core:65705] [ruby-trunk - Feature #10378] " mail
` (9 subsequent siblings)
10 siblings, 0 replies; 11+ messages in thread
From: mail @ 2014-10-13 19:51 UTC (permalink / raw
To: ruby-core
Issue #10378 has been reported by gogo tanaka.
----------------------------------------
Feature #10378: [PATCH 0/3] It's better (1 + 0i).real? return true
https://bugs.ruby-lang.org/issues/10378
* Author: gogo tanaka
* Status: Open
* Priority: Normal
* Assignee:
* Category: core
* Target version: current: 2.2.0
----------------------------------------
Right now, `Complex#real?` return `false` anytime.
I suppose `#is_a?(Complex)` is enough to check whether a object is `Complex`'s object or not.
(I have to admire `#real?` is more useful than `#is_a?(Complex)`)
But what we really want to know is whether a object whose class has `Numeric` as superclass is equal to real number or not.
Actually whichever is ok, modifying `#real?` or implementing as new method(e.g #real_num? ... :(
Anyway, I wanna method like that for `Complex`.
```cpp
static VALUE
nucomp_real_p(VALUE self)
{
get_dat1(self);
if (rb_equal(dat->imag, INT2FIX(0))) {
return Qtrue;
}
return Qfalse;
}
```
By the way, I can find two coding styles through ruby source code.
Which is prefer? it doesn't matter?
```cpp
if(...)
return ...
retrun ...
```
or
```cpp
if(...) {
return ...
}
retrun ...
```
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 11+ messages in thread
* [ruby-core:65705] [ruby-trunk - Feature #10378] [PATCH 0/3] It's better (1 + 0i).real? return true
[not found] <redmine.issue-10378.20141013195156@ruby-lang.org>
2014-10-13 19:51 ` [ruby-core:65680] [ruby-trunk - Feature #10378] [Open] [PATCH 0/3] It's better (1 + 0i).real? return true mail
@ 2014-10-14 17:30 ` mail
2014-10-26 3:22 ` [ruby-core:65905] " mail
` (8 subsequent siblings)
10 siblings, 0 replies; 11+ messages in thread
From: mail @ 2014-10-14 17:30 UTC (permalink / raw
To: ruby-core
Issue #10378 has been updated by gogo tanaka.
I can find more useful function `f_zero_p `.
```c
static VALUE
nucomp_real_p(VALUE self)
{
get_dat1(self);
return f_zero_p(dat->imag);
}
```
----------------------------------------
Feature #10378: [PATCH 0/3] It's better (1 + 0i).real? return true
https://bugs.ruby-lang.org/issues/10378#change-49437
* Author: gogo tanaka
* Status: Open
* Priority: Normal
* Assignee:
* Category: core
* Target version: current: 2.2.0
----------------------------------------
Right now, `Complex#real?` return `false` anytime.
I suppose `#is_a?(Complex)` is enough to check whether a object is `Complex`'s object or not.
(I have to admire `#real?` is more useful than `#is_a?(Complex)`)
But what we really want to know is whether a object whose class has `Numeric` as superclass is equal to real number or not.
Actually whichever is ok, modifying `#real?` or implementing as new method(e.g #real_num? ... :(
Anyway, I wanna method like that for `Complex`.
```cpp
static VALUE
nucomp_real_p(VALUE self)
{
get_dat1(self);
if (rb_equal(dat->imag, INT2FIX(0))) {
return Qtrue;
}
return Qfalse;
}
```
By the way, I can find two coding styles through ruby source code.
Which is prefer? it doesn't matter?
```cpp
if(...)
return ...
retrun ...
```
or
```cpp
if(...) {
return ...
}
retrun ...
```
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 11+ messages in thread
* [ruby-core:65905] [ruby-trunk - Feature #10378] [PATCH 0/3] It's better (1 + 0i).real? return true
[not found] <redmine.issue-10378.20141013195156@ruby-lang.org>
2014-10-13 19:51 ` [ruby-core:65680] [ruby-trunk - Feature #10378] [Open] [PATCH 0/3] It's better (1 + 0i).real? return true mail
2014-10-14 17:30 ` [ruby-core:65705] [ruby-trunk - Feature #10378] " mail
@ 2014-10-26 3:22 ` mail
2014-10-26 4:12 ` [ruby-core:65906] " sawadatsuyoshi
` (7 subsequent siblings)
10 siblings, 0 replies; 11+ messages in thread
From: mail @ 2014-10-26 3:22 UTC (permalink / raw
To: ruby-core
Issue #10378 has been updated by gogo tanaka.
File update_NEWS.patch added
File add_tests.patch added
File update_Complex#real_.patch added
There are not any arguments or opinions, I've made patches(implement, test, updating NEWS ) anyway.
Please check it.
Thanks.
----------------------------------------
Feature #10378: [PATCH 0/3] It's better (1 + 0i).real? return true
https://bugs.ruby-lang.org/issues/10378#change-49644
* Author: gogo tanaka
* Status: Open
* Priority: Normal
* Assignee:
* Category: core
* Target version: current: 2.2.0
----------------------------------------
Right now, `Complex#real?` return `false` anytime.
I suppose `#is_a?(Complex)` is enough to check whether a object is `Complex`'s object or not.
(I have to admire `#real?` is more useful than `#is_a?(Complex)`)
But what we really want to know is whether a object whose class has `Numeric` as superclass is equal to real number or not.
Actually whichever is ok, modifying `#real?` or implementing as new method(e.g #real_num? ... :(
Anyway, I wanna method like that for `Complex`.
```cpp
static VALUE
nucomp_real_p(VALUE self)
{
get_dat1(self);
if (rb_equal(dat->imag, INT2FIX(0))) {
return Qtrue;
}
return Qfalse;
}
```
By the way, I can find two coding styles through ruby source code.
Which is prefer? it doesn't matter?
```cpp
if(...)
return ...
retrun ...
```
or
```cpp
if(...) {
return ...
}
retrun ...
```
---Files--------------------------------
update_NEWS.patch (716 Bytes)
add_tests.patch (848 Bytes)
update_Complex#real_.patch (1.18 KB)
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 11+ messages in thread
* [ruby-core:65906] [ruby-trunk - Feature #10378] [PATCH 0/3] It's better (1 + 0i).real? return true
[not found] <redmine.issue-10378.20141013195156@ruby-lang.org>
` (2 preceding siblings ...)
2014-10-26 3:22 ` [ruby-core:65905] " mail
@ 2014-10-26 4:12 ` sawadatsuyoshi
2014-10-26 6:29 ` [ruby-core:65908] " mail
` (6 subsequent siblings)
10 siblings, 0 replies; 11+ messages in thread
From: sawadatsuyoshi @ 2014-10-26 4:12 UTC (permalink / raw
To: ruby-core
Issue #10378 has been updated by Tsuyoshi Sawada.
gogo tanakaさん、
他スレッドでのコメントありがとうございます。決して否定的に思って欲しくないのですが、gogo tanakaさんの(他のサイトも含む)いくつかの投稿で、"admire"という単語を"admit"のつもりで使っているのではないかと思える箇所があります。初めはタイプミスかと思いましたが、繰り返されているようなので、きっと間違って覚えているのではないかと思います。そのままだと意味が分からなくなるときがあるので、今後のよりよい投稿をなされるよう、ここで指摘させていただきます。
----------------------------------------
Feature #10378: [PATCH 0/3] It's better (1 + 0i).real? return true
https://bugs.ruby-lang.org/issues/10378#change-49646
* Author: gogo tanaka
* Status: Open
* Priority: Normal
* Assignee:
* Category: core
* Target version: current: 2.2.0
----------------------------------------
Right now, `Complex#real?` return `false` anytime.
I suppose `#is_a?(Complex)` is enough to check whether a object is `Complex`'s object or not.
(I have to admire `#real?` is more useful than `#is_a?(Complex)`)
But what we really want to know is whether a object whose class has `Numeric` as superclass is equal to real number or not.
Actually whichever is ok, modifying `#real?` or implementing as new method(e.g #real_num? ... :(
Anyway, I wanna method like that for `Complex`.
```cpp
static VALUE
nucomp_real_p(VALUE self)
{
get_dat1(self);
if (rb_equal(dat->imag, INT2FIX(0))) {
return Qtrue;
}
return Qfalse;
}
```
By the way, I can find two coding styles through ruby source code.
Which is prefer? it doesn't matter?
```cpp
if(...)
return ...
retrun ...
```
or
```cpp
if(...) {
return ...
}
retrun ...
```
---Files--------------------------------
update_NEWS.patch (716 Bytes)
add_tests.patch (848 Bytes)
update_Complex#real_.patch (1.18 KB)
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 11+ messages in thread
* [ruby-core:65908] [ruby-trunk - Feature #10378] [PATCH 0/3] It's better (1 + 0i).real? return true
[not found] <redmine.issue-10378.20141013195156@ruby-lang.org>
` (3 preceding siblings ...)
2014-10-26 4:12 ` [ruby-core:65906] " sawadatsuyoshi
@ 2014-10-26 6:29 ` mail
2014-10-28 8:39 ` [ruby-core:65939] " t_nissie
` (5 subsequent siblings)
10 siblings, 0 replies; 11+ messages in thread
From: mail @ 2014-10-26 6:29 UTC (permalink / raw
To: ruby-core
Issue #10378 has been updated by gogo tanaka.
Tsuyoshi Sawada さん
こんにちは. 22年間誤用しておりました.. お恥ずかしい.
ご指摘をするのも心苦しいと察します、わざわざお伝え頂けるとは本当に嬉しく思います.
お陰さまで苦手な英語を一歩前進させる事が出来ました. ありがとうございました!!
話は変わりますが、Tsuyoshi Sawada さん が面白いアイディアを沢山投稿されて、ステキだと思っています.
実際に実装されるまでは色々考えなければいけない所があるんでしょうが(もちろん僕も偉そうな事は決して言えません)
単純に考えを深めたりアイディアを生むきっかけとして僕自身大変楽しく拝見させて頂いております.
今後ともよろしくお願い致します.
----------------------------------------
Feature #10378: [PATCH 0/3] It's better (1 + 0i).real? return true
https://bugs.ruby-lang.org/issues/10378#change-49647
* Author: gogo tanaka
* Status: Open
* Priority: Normal
* Assignee:
* Category: core
* Target version: current: 2.2.0
----------------------------------------
Right now, `Complex#real?` return `false` anytime.
I suppose `#is_a?(Complex)` is enough to check whether a object is `Complex`'s object or not.
(I have to admire `#real?` is more useful than `#is_a?(Complex)`)
But what we really want to know is whether a object whose class has `Numeric` as superclass is equal to real number or not.
Actually whichever is ok, modifying `#real?` or implementing as new method(e.g #real_num? ... :(
Anyway, I wanna method like that for `Complex`.
```cpp
static VALUE
nucomp_real_p(VALUE self)
{
get_dat1(self);
if (rb_equal(dat->imag, INT2FIX(0))) {
return Qtrue;
}
return Qfalse;
}
```
By the way, I can find two coding styles through ruby source code.
Which is prefer? it doesn't matter?
```cpp
if(...)
return ...
retrun ...
```
or
```cpp
if(...) {
return ...
}
retrun ...
```
---Files--------------------------------
update_NEWS.patch (716 Bytes)
add_tests.patch (848 Bytes)
update_Complex#real_.patch (1.18 KB)
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 11+ messages in thread
* [ruby-core:65939] [ruby-trunk - Feature #10378] [PATCH 0/3] It's better (1 + 0i).real? return true
[not found] <redmine.issue-10378.20141013195156@ruby-lang.org>
` (4 preceding siblings ...)
2014-10-26 6:29 ` [ruby-core:65908] " mail
@ 2014-10-28 8:39 ` t_nissie
2014-10-28 16:22 ` [ruby-core:65951] " mail
` (4 subsequent siblings)
10 siblings, 0 replies; 11+ messages in thread
From: t_nissie @ 2014-10-28 8:39 UTC (permalink / raw
To: ruby-core
Issue #10378 has been updated by Takeshi Nishimatsu.
Objection.
Especially for Float, Complex(1.0,0.0) and Complex(1.0,-0.0) have meanings:
sqrt[-x+i(+0)]=i*sqrt(x)
sqrt[-x+i(-0)]=-i*sqrt(x)
So, they are complex. Not real.
And, please see the man page of cproj(3), though cproj is not implemented in Ruby.
Please see Goldberg's review.
http://docs.oracle.com/cd/E19957-01/806-4847/ncg_goldberg.html (EUC encoded)
http://iss.ndl.go.jp/books/R100000039-I001404293-00
@article{goldberg1991ecs,
title={What every computer scientist should know about floating-point arithmetic},
author={David Goldberg},
journal={ACM Computing Surveys},
volume={23},
number={1},
pages={5--48},
year={1991}}
http://dl.acm.org/citation.cfm?id=103163
This good review is also linked from https://bugs.ruby-lang.org/projects/ruby/wiki/HowToReportJa .
BTW, I do not like
-1.0-0.0i => (-1.0+0.0i) ,
though I know that it is translated as
-1.0-0.0i => Complex(-1.0,0.0)-Complex(0.0,-0.0) => (-1.0+0.0i) .
----------------------------------------
Feature #10378: [PATCH 0/3] It's better (1 + 0i).real? return true
https://bugs.ruby-lang.org/issues/10378#change-49677
* Author: gogo tanaka
* Status: Open
* Priority: Normal
* Assignee:
* Category: core
* Target version: current: 2.2.0
----------------------------------------
Right now, `Complex#real?` return `false` anytime.
I suppose `#is_a?(Complex)` is enough to check whether a object is `Complex`'s object or not.
(I have to admire `#real?` is more useful than `#is_a?(Complex)`)
But what we really want to know is whether a object whose class has `Numeric` as superclass is equal to real number or not.
Actually whichever is ok, modifying `#real?` or implementing as new method(e.g #real_num? ... :(
Anyway, I wanna method like that for `Complex`.
```cpp
static VALUE
nucomp_real_p(VALUE self)
{
get_dat1(self);
if (rb_equal(dat->imag, INT2FIX(0))) {
return Qtrue;
}
return Qfalse;
}
```
By the way, I can find two coding styles through ruby source code.
Which is prefer? it doesn't matter?
```cpp
if(...)
return ...
retrun ...
```
or
```cpp
if(...) {
return ...
}
retrun ...
```
---Files--------------------------------
update_NEWS.patch (716 Bytes)
add_tests.patch (848 Bytes)
update_Complex#real_.patch (1.18 KB)
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 11+ messages in thread
* [ruby-core:65951] [ruby-trunk - Feature #10378] [PATCH 0/3] It's better (1 + 0i).real? return true
[not found] <redmine.issue-10378.20141013195156@ruby-lang.org>
` (5 preceding siblings ...)
2014-10-28 8:39 ` [ruby-core:65939] " t_nissie
@ 2014-10-28 16:22 ` mail
2014-10-29 0:49 ` [ruby-core:65962] " t_nissie
` (3 subsequent siblings)
10 siblings, 0 replies; 11+ messages in thread
From: mail @ 2014-10-28 16:22 UTC (permalink / raw
To: ruby-core
Issue #10378 has been updated by gogo tanaka.
@Takeshi Nishimatsu san
Thank you for your comments and sharing good article.
From this article, your point-out might be right. I admit `Complex(x, 0.0)` is not truly real.
And I suppose `-1.0-0.0i` not be `-1.0+0.0i` too.
Aside from that, as I said `#is_a?(Complex)` or current `#real?` can be the way we check whether a number is truly real or not.
Actually whichever is ok, modifying #real? or implementing as new method.
What I want right now is checking whether a act as real.
So lets run through a few scenarios (I'd better find more practical example... * (
```
c = (2.0 + 1.0i)
a1 = (-1.0+0.0i)
p c * a1
a2 = (-1.0-0.0i)
p c * a2
a3 = (-1.0+0i)
p c * a3
a4 = -1.0
p c * a4
```
a1~4 act as same. When I check a5 is also same, I have to write
```
a5.is_a?(Complex) && a5.imag.zero?
```
It's little bit diffuse.
Thanks.
----------------------------------------
Feature #10378: [PATCH 0/3] It's better (1 + 0i).real? return true
https://bugs.ruby-lang.org/issues/10378#change-49686
* Author: gogo tanaka
* Status: Open
* Priority: Normal
* Assignee:
* Category: core
* Target version: current: 2.2.0
----------------------------------------
Right now, `Complex#real?` return `false` anytime.
I suppose `#is_a?(Complex)` is enough to check whether a object is `Complex`'s object or not.
(I have to admire `#real?` is more useful than `#is_a?(Complex)`)
But what we really want to know is whether a object whose class has `Numeric` as superclass is equal to real number or not.
Actually whichever is ok, modifying `#real?` or implementing as new method(e.g #real_num? ... :(
Anyway, I wanna method like that for `Complex`.
```cpp
static VALUE
nucomp_real_p(VALUE self)
{
get_dat1(self);
if (rb_equal(dat->imag, INT2FIX(0))) {
return Qtrue;
}
return Qfalse;
}
```
By the way, I can find two coding styles through ruby source code.
Which is prefer? it doesn't matter?
```cpp
if(...)
return ...
retrun ...
```
or
```cpp
if(...) {
return ...
}
retrun ...
```
---Files--------------------------------
update_NEWS.patch (716 Bytes)
add_tests.patch (848 Bytes)
update_Complex#real_.patch (1.18 KB)
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 11+ messages in thread
* [ruby-core:65962] [ruby-trunk - Feature #10378] [PATCH 0/3] It's better (1 + 0i).real? return true
[not found] <redmine.issue-10378.20141013195156@ruby-lang.org>
` (6 preceding siblings ...)
2014-10-28 16:22 ` [ruby-core:65951] " mail
@ 2014-10-29 0:49 ` t_nissie
2014-10-30 20:49 ` [ruby-core:66024] " mail
` (2 subsequent siblings)
10 siblings, 0 replies; 11+ messages in thread
From: t_nissie @ 2014-10-29 0:49 UTC (permalink / raw
To: ruby-core
Issue #10378 has been updated by Takeshi Nishimatsu.
FYI, on Julia:
```
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
```
----------------------------------------
Feature #10378: [PATCH 0/3] It's better (1 + 0i).real? return true
https://bugs.ruby-lang.org/issues/10378#change-49696
* Author: gogo tanaka
* Status: Open
* Priority: Normal
* Assignee:
* Category: core
* Target version: current: 2.2.0
----------------------------------------
Right now, `Complex#real?` return `false` anytime.
I suppose `#is_a?(Complex)` is enough to check whether a object is `Complex`'s object or not.
(I have to admire `#real?` is more useful than `#is_a?(Complex)`)
But what we really want to know is whether a object whose class has `Numeric` as superclass is equal to real number or not.
Actually whichever is ok, modifying `#real?` or implementing as new method(e.g #real_num? ... :(
Anyway, I wanna method like that for `Complex`.
```cpp
static VALUE
nucomp_real_p(VALUE self)
{
get_dat1(self);
if (rb_equal(dat->imag, INT2FIX(0))) {
return Qtrue;
}
return Qfalse;
}
```
By the way, I can find two coding styles through ruby source code.
Which is prefer? it doesn't matter?
```cpp
if(...)
return ...
retrun ...
```
or
```cpp
if(...) {
return ...
}
retrun ...
```
---Files--------------------------------
update_NEWS.patch (716 Bytes)
add_tests.patch (848 Bytes)
update_Complex#real_.patch (1.18 KB)
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 11+ messages in thread
* [ruby-core:66024] [ruby-trunk - Feature #10378] [PATCH 0/3] It's better (1 + 0i).real? return true
[not found] <redmine.issue-10378.20141013195156@ruby-lang.org>
` (7 preceding siblings ...)
2014-10-29 0:49 ` [ruby-core:65962] " t_nissie
@ 2014-10-30 20:49 ` mail
2014-10-31 1:20 ` [ruby-core:66028] " t_nissie
2014-11-05 21:40 ` [ruby-core:66107] " mail
10 siblings, 0 replies; 11+ messages in thread
From: mail @ 2014-10-30 20:49 UTC (permalink / raw
To: ruby-core
Issue #10378 has been updated by gogo tanaka.
@Takeshi Nishimatsu san
Thank for info, how do you think about my point?
----------------------------------------
Feature #10378: [PATCH 0/3] It's better (1 + 0i).real? return true
https://bugs.ruby-lang.org/issues/10378#change-49745
* Author: gogo tanaka
* Status: Open
* Priority: Normal
* Assignee:
* Category: core
* Target version: current: 2.2.0
----------------------------------------
Right now, `Complex#real?` return `false` anytime.
I suppose `#is_a?(Complex)` is enough to check whether a object is `Complex`'s object or not.
(I have to admire `#real?` is more useful than `#is_a?(Complex)`)
But what we really want to know is whether a object whose class has `Numeric` as superclass is equal to real number or not.
Actually whichever is ok, modifying `#real?` or implementing as new method(e.g #real_num? ... :(
Anyway, I wanna method like that for `Complex`.
```cpp
static VALUE
nucomp_real_p(VALUE self)
{
get_dat1(self);
if (rb_equal(dat->imag, INT2FIX(0))) {
return Qtrue;
}
return Qfalse;
}
```
By the way, I can find two coding styles through ruby source code.
Which is prefer? it doesn't matter?
```cpp
if(...)
return ...
retrun ...
```
or
```cpp
if(...) {
return ...
}
retrun ...
```
---Files--------------------------------
update_NEWS.patch (716 Bytes)
add_tests.patch (848 Bytes)
update_Complex#real_.patch (1.18 KB)
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 11+ messages in thread
* [ruby-core:66028] [ruby-trunk - Feature #10378] [PATCH 0/3] It's better (1 + 0i).real? return true
[not found] <redmine.issue-10378.20141013195156@ruby-lang.org>
` (8 preceding siblings ...)
2014-10-30 20:49 ` [ruby-core:66024] " mail
@ 2014-10-31 1:20 ` t_nissie
2014-11-05 21:40 ` [ruby-core:66107] " mail
10 siblings, 0 replies; 11+ messages in thread
From: t_nissie @ 2014-10-31 1:20 UTC (permalink / raw
To: ruby-core
Issue #10378 has been updated by Takeshi Nishimatsu.
> to know whether a object whose class has Numeric as superclass is equal to real number or not.
Simplly, `a.real? || a.imag.zero?` may be enough for me, so far.
```
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
```
Sorry, but I cannot find any reason to change the current
definition of `Numeric#real?` and to define a new method.
----------------------------------------
Feature #10378: [PATCH 0/3] It's better (1 + 0i).real? return true
https://bugs.ruby-lang.org/issues/10378#change-49748
* Author: gogo tanaka
* Status: Open
* Priority: Normal
* Assignee:
* Category: core
* Target version: current: 2.2.0
----------------------------------------
Right now, `Complex#real?` return `false` anytime.
I suppose `#is_a?(Complex)` is enough to check whether a object is `Complex`'s object or not.
(I have to admire `#real?` is more useful than `#is_a?(Complex)`)
But what we really want to know is whether a object whose class has `Numeric` as superclass is equal to real number or not.
Actually whichever is ok, modifying `#real?` or implementing as new method(e.g #real_num? ... :(
Anyway, I wanna method like that for `Complex`.
```cpp
static VALUE
nucomp_real_p(VALUE self)
{
get_dat1(self);
if (rb_equal(dat->imag, INT2FIX(0))) {
return Qtrue;
}
return Qfalse;
}
```
By the way, I can find two coding styles through ruby source code.
Which is prefer? it doesn't matter?
```cpp
if(...)
return ...
retrun ...
```
or
```cpp
if(...) {
return ...
}
retrun ...
```
---Files--------------------------------
update_NEWS.patch (716 Bytes)
add_tests.patch (848 Bytes)
update_Complex#real_.patch (1.18 KB)
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 11+ messages in thread
* [ruby-core:66107] [ruby-trunk - Feature #10378] [PATCH 0/3] It's better (1 + 0i).real? return true
[not found] <redmine.issue-10378.20141013195156@ruby-lang.org>
` (9 preceding siblings ...)
2014-10-31 1:20 ` [ruby-core:66028] " t_nissie
@ 2014-11-05 21:40 ` mail
10 siblings, 0 replies; 11+ messages in thread
From: mail @ 2014-11-05 21:40 UTC (permalink / raw
To: ruby-core
Issue #10378 has been updated by gogo tanaka.
@Takeshi Nishimatsu san
OK, it does make sense. thanks.
----------------------------------------
Feature #10378: [PATCH 0/3] It's better (1 + 0i).real? return true
https://bugs.ruby-lang.org/issues/10378#change-49819
* Author: gogo tanaka
* Status: Open
* Priority: Normal
* Assignee:
* Category: core
* Target version: current: 2.2.0
----------------------------------------
Right now, `Complex#real?` return `false` anytime.
I suppose `#is_a?(Complex)` is enough to check whether a object is `Complex`'s object or not.
(I have to admire `#real?` is more useful than `#is_a?(Complex)`)
But what we really want to know is whether a object whose class has `Numeric` as superclass is equal to real number or not.
Actually whichever is ok, modifying `#real?` or implementing as new method(e.g #real_num? ... :(
Anyway, I wanna method like that for `Complex`.
```cpp
static VALUE
nucomp_real_p(VALUE self)
{
get_dat1(self);
if (rb_equal(dat->imag, INT2FIX(0))) {
return Qtrue;
}
return Qfalse;
}
```
By the way, I can find two coding styles through ruby source code.
Which is prefer? it doesn't matter?
```cpp
if(...)
return ...
retrun ...
```
or
```cpp
if(...) {
return ...
}
retrun ...
```
---Files--------------------------------
update_NEWS.patch (716 Bytes)
add_tests.patch (848 Bytes)
update_Complex#real_.patch (1.18 KB)
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2014-11-05 21:52 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <redmine.issue-10378.20141013195156@ruby-lang.org>
2014-10-13 19:51 ` [ruby-core:65680] [ruby-trunk - Feature #10378] [Open] [PATCH 0/3] It's better (1 + 0i).real? return true mail
2014-10-14 17:30 ` [ruby-core:65705] [ruby-trunk - Feature #10378] " mail
2014-10-26 3:22 ` [ruby-core:65905] " mail
2014-10-26 4:12 ` [ruby-core:65906] " sawadatsuyoshi
2014-10-26 6:29 ` [ruby-core:65908] " mail
2014-10-28 8:39 ` [ruby-core:65939] " t_nissie
2014-10-28 16:22 ` [ruby-core:65951] " mail
2014-10-29 0:49 ` [ruby-core:65962] " t_nissie
2014-10-30 20:49 ` [ruby-core:66024] " mail
2014-10-31 1:20 ` [ruby-core:66028] " t_nissie
2014-11-05 21:40 ` [ruby-core:66107] " mail
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).