1
你好这里的人是我的问题: 如何减少浮点数只有小数? %.1对我来说是最好的,但是当我与另一个像unNumero = 1.7f的浮点比较时,代码不会这样做。我认为,因为浮动有更多的数字。我该如何解决这个问题。我需要将stopCrono的结果与一些随机浮点数进行比较,但限制为2位小数。对不起,我的英语不是我的母语。 这是我的代码浮点数小数点比较cocos2d
- (无效)startCrono:(ccTime)增量{
totalTime += delta ;
currentTime = totalTime;
timeLimit = 2.0f;
[timeLabel setString:[NSString stringWithFormat:@"%.1f ",currentTime ]];
if (currentTime >= timeLimit) {
[self unschedule:_cmd];
}
} - (无效)stopCrono:(ccTime)crono2 {
[self unschedule:@selector(startCrono:)];
unNumero = 1.7f;
if(unNumero == currentTime){
CCLOG(@"OK");
}
}
如果staetment不起作用CClog不打印确定当我停止我的crono在1.7
非常感谢! – user1832082