Q:

Halving a number loses fractional part

I want to show the halved value of a number on a UILabel. To do so, I tried getting the number using a UITextField, formatted the number from a NSString to a NSNumber and then divided by 2.
After that I wanted to show it on the UILabel but it doesn't show anything after the comma (decimal mark). Any idea how to solve this? I just need two digits after the comma.
This is my current UIButton code: 
// first get the input
NSString *inputValue = self.numberInput.text;
NSLog(@"given number: %@", inputValue);

// divide the input by 2 & get the output
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
formatter.numberStyle = NSNumberFormatterDecimalStyle;
NSNumber *myNumber = [formatter numberFromString:inputValue];
NSNumber *toDivide = [NSNumber numberWithFloat:2];

NSNumber *dividedNumber = [NSNumber numberWithInt:[myNumber floatValue] / [toDivide floatValue]];
NSLog(@"divided value: %@", dividedNumber);

// print it out on the firstBill Label
self.firstBill.text = [NSString stringWithFormat:@"%.2f",[dividedNumber floatValue]];

Example Output:
2015-08-18 20:03:02.021 Week one[1364:37640] given number: 123.54
2015-08-18 20:03:02.022 Week one[1364:37640] divided value: 61

and I need something like 
2015-08-18 20:03:02.021 Week one[1364:37640] given number: 123.54
2015-08-18 20:03:02.022 Week one[1364:37640] divided value: 61.77

A:

You're using numberWithInt: to store the result of the division; this discards any fractional part.
You would do better to use NSNumber boxing:
@([myNumber floatValue] / [toDivide floatValue])

The compiler knows the type of the expression and will use the correct NSNumber constructor for you.

