Why is "." a decimal number? (NSScanner question)
Why is "." a decimal number? (NSScanner question)
- Subject: Why is "." a decimal number? (NSScanner question)
- From: Jim Rankin <email@hidden>
- Date: Fri, 4 Jun 2004 15:38:27 -0400
Why does NSScanner consider "." to be a decimal number? The following
program:
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSDecimal d;
NSScanner *dotsScanner = [NSScanner scannerWithString:@"...."];
while ([dotsScanner scanDecimal:&d])
NSLog(@"scanned %@", [NSDecimalNumber
decimalNumberWithDecimal:d]);
[pool release];
return 0;
}
gives the following output:
2004-06-04 15:34:59.039 dotIsAdecimalNumber[1252] scanned 0
2004-06-04 15:34:59.041 dotIsAdecimalNumber[1252] scanned 0
2004-06-04 15:34:59.041 dotIsAdecimalNumber[1252] scanned 0
2004-06-04 15:34:59.041 dotIsAdecimalNumber[1252] scanned 0
dotIsAdecimalNumber has exited with status 0.
Does anyone ever write "." and expect it to be interpreted to mean "0"?
Or is this a bug?
Thanks,
-jimbo
Excelsior! XML Marshaller for Cocoa
http://www.homepage.mac.com/jimbokun/Excelsior.html
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.