diff options
| author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-04 08:55:20 +0000 |
|---|---|---|
| committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-04 08:55:20 +0000 |
| commit | f6ffe5d09034c83af8644c46311a60e79abc6a1f (patch) | |
| tree | 2a0462953cab2a58d7cc1d9e9fb952e41725b5df /complex.c | |
| parent | 0a91b021fb96dbed61ae0ad113b8bdd43a85efc0 (diff) | |
| download | ruby-f6ffe5d09034c83af8644c46311a60e79abc6a1f.tar.gz ruby-f6ffe5d09034c83af8644c46311a60e79abc6a1f.tar.xz ruby-f6ffe5d09034c83af8644c46311a60e79abc6a1f.zip | |
merges r20474 from trunk into ruby_1_9_1.
* complex.c (nurat_{to_s,inspect}): provides better representation
for in-finite imag part.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_1@20502 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'complex.c')
| -rw-r--r-- | complex.c | 15 |
1 files changed, 5 insertions, 10 deletions
@@ -922,6 +922,8 @@ nucomp_to_s(VALUE self) rb_str_cat2(s, !impos ? "-" : "+"); rb_str_concat(s, f_to_s(f_abs(dat->imag))); + if (!rb_isdigit(RSTRING_PTR(s)[RSTRING_LEN(s) - 1])) + rb_str_cat2(s, "*"); rb_str_cat2(s, "i"); return s; @@ -930,18 +932,11 @@ nucomp_to_s(VALUE self) static VALUE nucomp_inspect(VALUE self) { - VALUE s, impos; - - get_dat1(self); - - impos = f_tpositive_p(dat->imag); + VALUE s; s = rb_str_new2("("); - rb_str_concat(s, f_inspect(dat->real)); - rb_str_cat2(s, !impos ? "-" : "+"); - - rb_str_concat(s, f_inspect(f_abs(dat->imag))); - rb_str_cat2(s, "i)"); + rb_str_concat(s, nucomp_to_s(self)); + rb_str_cat2(s, ")"); return s; } |
