【发布时间】:2011-05-12 15:56:29
【问题描述】:
我正在添加一个数组中保存的值,但总和是 +1 实际应该是什么。
//update totalscore
uint newTotalScore;
for (uint i=0; i< [bestscoresArray count] ; i++) {
newTotalScore += [[bestscoresArray objectAtIndex:i] intValue];
}
totalscore = newTotalScore;
//输出 l1bestscore=15900, l2bestscore=7800, l3bestscore=81000, l4bestscore=81000, l5bestscore=0, l6bestscore=0, l7bestscore=0, l8bestscore=0, l9bestscore=0, l10bestscore=0, totalscore=185701
如您所见,总分输出为 185701,但所有值的总和为 185700。
有人知道为什么会发生这种情况吗?
谢谢,
标记
【问题讨论】:
标签: iphone objective-c arrays math integer