calculator - how to add a decimal to a float value Objective C -


i trying create calculator , can't find proper code add decimal current code... suggestions? how number buttons work:

- (ibaction)number9:(id)sender { number = number * 10; number = number + 9; _textbox.text = [nsstring stringwithformat:@"%i", number];} 

and example of how methods work.

- (ibaction)multbutton:(id)sender { if (hiddensum == 0) {     hiddensum = number; } else {     switch (method) {         case 1:             hiddensum = hiddensum + number;             break;         case 2:             hiddensum = hiddensum - number;             break;         case 3:             hiddensum = hiddensum * number;             break;         case 4:             hiddensum = hiddensum / number;             break;         default:             break;     }}     method = 3;     number = 0; } 

if need cast integer float value can use plus operator on them help, not sure if asked cast.

your code shows number integer , pretty sure result of calculations should float hiddensum float if right,

here example how may cast integer float

int number = 10;

float hiddensum = [[nsnumber numberwithint: number] floatvalue]


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -