Total Array as Decimal not Int.
So Im using this code to add all the contents of an array and get a total numerical value out of it. It works really good with one problem... it works with intigers and i need decimals too. If the array has 3.4,1.5, and 7.0 it gives 11 but i need it to give 11.9. Anyone found out how to do this? Do you use doubles? Thanks!
int sum=0;
for(int x=0; x < [mainDelegate.lastcitieslc count]; x++)
{
sum += [[mainDelegate.lastcitieslc objectAtIndex:x] intValue];
}
[mainDelegate.actsections replaceObjectAtIndex:0 withObject:[NSString stringWithFormat:@"%d", sum]];
|