2013-04-02 4 views
0
NSNumber *weekNum = [dictionary valueForKey:@"inSeasonFor"]; 
NSDecimalNumber *newWeekNum = ([weekNum intValue] *2)/4; 
NSLog(@"%", [newWeekNum decimalValue]); 

weekNum * 2를 4로 나누고 십진수 값을 유지하고 인쇄하려면 어떻게해야합니까?ios : NSLog 표시 십진수 값

답변

1

당신은 소수 부분도 원한다는 것을 의미합니까?

NSNumber *weekNum = [dictionary valueForKey:@"inSeasonFor"]; 
// multiplication by 2 followed by division by 4 is division by 2 
NSLog(@"%f", [weekNum intValue]/2.0f); 

// intfloat를 사용하여 해결할 수도 있습니다.