diff options
author | mrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-05-09 04:52:57 +0000 |
---|---|---|
committer | mrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-05-09 04:52:57 +0000 |
commit | ca927d60f4e6b82c61afd1447112abc2157ff622 (patch) | |
tree | 14b9b93f056784ee0346b2a2f323a24d74eb1936 /complex.c | |
parent | d3e5a29361a75f46c471b404479693bd6359ff0f (diff) |
* complex.c (string_to_c_internal): support scientific notation.
patched by Tinco Andringa. https://github.com/ruby/ruby/pull/16
[ruby-core:36046][Bug #4655]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'complex.c')
-rw-r--r-- | complex.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -1498,6 +1498,7 @@ string_to_c_internal(VALUE self) m = f_match(comp_pat2, s); if (NIL_P(m)) return rb_assoc_new(Qnil, self); + /* string is of form "x+yi" */ sr = f_aref(m, INT2FIX(1)); if (NIL_P(f_aref(m, INT2FIX(2)))) si = Qnil; @@ -1518,7 +1519,7 @@ string_to_c_internal(VALUE self) if (!NIL_P(sr)) { if (strchr(RSTRING_PTR(sr), '/')) r = f_to_r(sr); - else if (strchr(RSTRING_PTR(sr), '.')) + else if (strchr(RSTRING_PTR(sr), '.') || strchr(RSTRING_PTR(sr), 'e') || strchr(RSTRING_PTR(sr), 'E')) r = f_to_f(sr); else r = f_to_i(sr); @@ -1526,7 +1527,7 @@ string_to_c_internal(VALUE self) if (!NIL_P(si)) { if (strchr(RSTRING_PTR(si), '/')) i = f_to_r(si); - else if (strchr(RSTRING_PTR(si), '.')) + else if (strchr(RSTRING_PTR(si), '.') || strchr(RSTRING_PTR(si), 'e') || strchr(RSTRING_PTR(si), 'E')) i = f_to_f(si); else i = f_to_i(si); |