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

How can I divide weekNum*2 by 4 and keep the decimal value and print it?

wwjdm
  • 2,568
  • 7
  • 32
  • 61

1 Answers1

1

You mean you want the fractional part as well, right?

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

//we can also use intfloat to resolve.

Anurag Sharma
  • 4,276
  • 2
  • 28
  • 44