Strange behaviour of scanFloat
Strange behaviour of scanFloat
- Subject: Strange behaviour of scanFloat
- From: Marco Michieli <email@hidden>
- Date: Sun, 6 Nov 2005 01:51:56 +0100
I'm using scanFloat to read float numbers from a text file, but I
realized that for example the string "273.4501" is converted to the
value "273.450104" and not "273.450100".
What's going on?
Here below the code and the correspondent log:
- (IBAction)test:(id)sender
{
NSScanner *theScanner;
NSString *scanString = @"237.4501";
float floatValue;
theScanner = [NSScanner scannerWithString:scanString];
if ([theScanner scanFloat:&floatValue]) {
NSLog(@"scanString:%@ scanned value:%f", scanString, floatValue);
} else {
NSLog(@"Scan Error");
}
}
2005-11-06 01:33:39.556 Test[622] scanString:237.4501 scanned value:
237.450104
Thanks for your help.
Best regards
Marco Michieli
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden