我想將字節轉換爲百分比。百分比將代表已上傳文件的總量。將字節轉換爲百分比
例如,我有:
int64_t totalBytesSent
int64_t totalBytesExpectedToSend
我想將其轉換成一個百分比(浮動)。
我已經試過這樣:
int64_t percentage = totalBytesSent/totalBytesExpectedToSend;
這:
[NSNumber numberWithLongLong:totalBytesSent];
[NSNumber numberWithLongLong:totalBytesExpectedToSend];
CGFloat = [totalBytesSent longLongValue]/[totalBytesExpectedToSend longLongValue];
我覺得我缺少在努力做 '字節數學' 的東西。有誰知道如何將字節轉換爲百分比?
大!這工作!謝謝!我沒有使用int64_t,它是來自塊中第三方庫的參數。 – tentmaking