Manolo
Manolo

Reputation: 479

SDK7 Format number

Need to format number four digits, no decimal, including 0 in the left, e.g. 0012. I am writing this code on Xcode for iPhone.

if (Tipo.selectedSegmentIndex == 2 ) { 
   float a = [N1.text floatValue];  float b = [N2.text floatValue];  
   float c = a*b;  
   R.text = [[NSString alloc] initWithFormat:@"%.0f",c];  
}

Upvotes: 0

Views: 99

Answers (1)

user4865920
user4865920

Reputation:

try something like this, let me know if helps

 self.yourTimeHere.text = [NSString stringWithFormat:@"%d.%d", (int)hours, (int)minutes];

Upvotes: 1

Related Questions