Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion strange string-to-float error on ubuntu karmic (alpha)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Nikolai Lugovoi  
View profile  
 More options Sep 27 2009, 5:24 pm
From: Nikolai Lugovoi <nlugo...@gmail.com>
Date: Sun, 27 Sep 2009 14:24:57 -0700 (PDT)
Local: Sun, Sep 27 2009 5:24 pm
Subject: Re: strange string-to-float error on ubuntu karmic (alpha)

On Sep 27, 11:19 am, Mathijs <bluescreen...@gmail.com> wrote:

> I did all updates/upgrades up to today, and installed REE (20090610).
> Installation worked, as did installation of all gems I use.
> When running a rails app, I noticed some strange behaviour(rails
> wanting to return xml for every request), which I traced down to the
> way strings are cast into floats:

> irb(main):001:0> "0.9".to_f
> => 9.0
> irb(main):002:0> "0.901".to_f
> => 901.0
> irb(main):003:0> "1.901".to_f
> => 1901.0

> Since to_f dives into c code, I'm backing off there.

> Anyone else seen this problem?

Hi,
I encountered same problem compiling old ruby-1.8.6  on Fedora 12,
that also uses GCC 4.4.1, as Karmic

At first I couldn't even believe it :), but then found, it was fixed
in later releases, since r16863.

And, funny, it was enough to set errno = 0 in  util.c/ruby_strtod() to
make parsing work again:

http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_7/util....

@@ -2103,6 +2112,7 @@
     const char *s2;
 #endif

+    errno = 0;
     sign = nz0 = nz = 0;
     dval(rv) = 0.;
     for (s = s00;;s++)

Hope that helps :)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.