I'm trying to convert decimal to base 36 and it works all the way until 35 decimal i get a value of z then when i enter 36 i get 0 instead of 10 anyone know whats wrong with my code
Code:
- (IBAction)button:(id)sender {
{
NSString *base36 = @"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
NSString *newvalue = @"";
NSString *g = @"";
int i = 0;
do {
int x ;
if (i == 0)
{
x = fmod(_field1.integerValue, [base36 length] );
}
else {
x = fmod([g doubleValue], [base36 length]);
}
NSString *y = [[NSString alloc] initWithFormat:@"%c", [base36 characterAtIndex:x]];
newvalue = [y stringByAppendingString:newvalue];
i++;
} while ([g intValue] != 0);
_field2.stringValue=newvalue;
}
}