Re: NSString doubleValue and zero
Re: NSString doubleValue and zero
- Subject: Re: NSString doubleValue and zero
- From: Daniel Aarno <email@hidden>
- Date: Mon, 24 Feb 2003 10:43:33 +0100
Tuesdayen den 18 February 2003 kl 22.30 skrev
email@hidden:
I use the message doubleValue to get a number value out of a string. If
the string is not a number then i need to store the string. My problem
is that if the string is not a number then doubleValue return 0.
But then how am i supposed to know when it is an actual number with
value 0 or a string that was not a number.
Any pointers appreciated
Well there probably is a more "correct" way of doing this but could you
not simply check the string?
...
char* buf;
double val;
val = [theString doubleValue];
if(val == 0) {
buf = [theString lossyCString];
if(buf[0] != '0') {
//Store string here
}
}
...
/Bishop
--
"We live in a primitive time... neither savage nor vise... Any rational
sociaty would either kill me or put me to some use." - Red Dragon
_______________________________________________
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.