[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug in [NSScanner scanDouble:]

From: Gregory Casamento
Subject: Re: Bug in [NSScanner scanDouble:]
Date: Mon, 28 Dec 2020 23:20:30 -0500


Regarding where to file... you can do it on github.  That shouldn't be a problem.

I'm curious, could this be a rounding error?  Double is supposed to have a precision of 15 decimal places.

Yours, GC

On Mon, Dec 28, 2020 at 6:30 PM Douglas Simons <Doug.Simons@eggplantsoftware.com> wrote:
Hi, sorry for posting a bug report here, but I seem to have lost my credentials for accessing the bug tracker.

The scanDouble: method of NSScanner is adding a tiny fraction to the value scanned (at least on Windows).

NSScanner *scanner = [NSScanner scannerWithString:@“197319600.000000”];
double val = 0.0;
[scanner scanDouble:&val];
NSLog(@"scanDouble got: %.9f", val);
// results in val having the value 197319600.00000012

Note that NSString’s doubleValue method doesn’t have this problem, so I’m using that to work around this problem for now.



Gregory Casamento
GNUstep Lead Developer / OLC, Principal Consultant
http://www.gnustep.org - http://heronsperch.blogspot.com
https://www.patreon.com/bePatron?u=352392 - Become a Patron
https://gf.me/u/x8m3sx - My GNUstep GoFundMe

reply via email to

[Prev in Thread] Current Thread [Next in Thread]