Mirror318
Mirror318

Reputation: 12663

For loop counter returning null?

I'm doing a class that will handle digit by digit arithmetic (i.e. arithmetic for numbers of any size).

I have this for loop which crashes on runtime, and complains that "column" is null. Can anyone shed some light on this?

for(column=0; column < bigger.length; column++) {
    NSLog(@"column %@", column);
    workingDigit = [y intAt:column] + [self intAt:column] + carry;
    carry = workingDigit / 10;      //make the carry not include the last digit of the sum
    workingDigit = workingDigit % 10;      //make the digit not include the carry

    [result insertString:[NSString stringWithFormat:@"%d", workingDigit] atIndex:0];
}

btw column is an int, declared as an instance variable. Also, that NSLog prints out "column (null)"

Upvotes: 0

Views: 83

Answers (1)

Mil0R3
Mil0R3

Reputation: 3956

You should use this:

NSLog(@"column %d", column);

Upvotes: 2

Related Questions