需要格式化四位數字,無小數,左側包括0 0012.我正在Xcode上爲iPhone編寫此代碼。SDK7格式編號
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];
}
需要格式化四位數字,無小數,左側包括0 0012.我正在Xcode上爲iPhone編寫此代碼。SDK7格式編號
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];
}
嘗試這樣的事情,讓我知道,如果之前你總是得到,並希望00你的結果數量有助於
self.yourTimeHere.text = [NSString stringWithFormat:@"%d.%d", (int)hours, (int)minutes];
這很適合我很久以前尋找的東西....非常感謝。 – Manolo
不用擔心......樂意幫忙...... – 2015-05-05 10:33:12
? –
你想顯示一個4位數的整數,但是你使用的是浮點數?我聞到那裏的東西。嘗試轉換爲int,然後格式化它。 – Abizern
嗨喬丹,我得到的是12而不是0012. – Manolo