[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #38640] GSScanDouble should use strtod
From: |
Larry Campbell |
Subject: |
[bug #38640] GSScanDouble should use strtod |
Date: |
Sun, 31 Mar 2013 17:55:40 +0000 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/536.28.10 (KHTML, like Gecko) Version/6.0.3 Safari/536.28.10 |
Follow-up Comment #1, bug #38640 (project gnustep):
More info:
We occasionally see things like this in the fpconfigloader log and in
configuration change confirmation emails:
2012-06-26 16:12:51.402 fpconfigloader[15552] Property "www" changed:
2012-06-26 16:12:51.402 fpconfigloader[15552] loadImbalanceFactor changed:
"1.9" => "1.9"
which is harmless but annoying. This turns out to be because the load
imbalance factor comes from the portal as an integer string, "90", which is
converted as follows:
[self setLoadImbalanceFactor:[NSNumber
numberWithDouble:(((double)[[soap_property
objectForKey:@"loadImbalanceFactor"] unsignedIntValue])/100.0) + 1.0]];
more concisely summarized as, essentially:
x = 90 / 100.0 + 1.0;
which is 1.9, but that can't be represented exactly, and actually results in
1.8999999999999999.
The problem is that -[NSString doubleValue], which is used by FPFile.m when
parsing stored dynamic config files, ends up calling GSScanDouble in
NSScanner.m, which does not use atof or strtod, instead using its own
home-grown parser that returns:
1.9000000000000001
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?38640>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/