Reputation: 489
Is there a way to keep the leading zeros when converting a string to an integer. For example say the string was "01" is there a way i could store it as an integer value of 01?
- (int) getNextHand{
int temp = [[numbersArray objectAtIndex:cardsDelt] intValue];
NSLog(@"Card %i: %i", cardsDelt, temp);
cardsDelt++;
return temp;
}
My numbersArray contains 4 leading zero numbers they are: "00" "01" "02" "03"
Upvotes: 2
Views: 1343
Reputation: 21221
Nope integers are numbers and 01
will be automatically be converted to 1
Upvotes: 2
Reputation: 272467
01
and 1
are two representations of the same integer value. If the leading digits contain information, then you have a string, not an integer.
Upvotes: 1