Sanchit Tak
Sanchit Tak

Reputation: 1

Converting String to long long value

In my application I have to convert string to long long data type and it should also be supported for Tiger OS.

So I can not directly use longLongValue on NSString because it is supported for Mac OS Version 10.5 and later.

So I am converting string value to long long by the following method :

+ (long long) convertToLongLong:(NSString*) inString
{
    return [[[[NSNumber alloc] initWithDouble:[inString doubleValue]] autorelease] longLongValue];
}

I just wanted to know will it required any overflow or underflow conditions, and if required then how to use that.

Upvotes: 0

Views: 1000

Answers (1)

Stephen Canon
Stephen Canon

Reputation: 106127

Convert to a C string, then use the C99 function strtoll( ), declared in <stdlib.h>.

Upvotes: 2

Related Questions