1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-23 08:13:27 +00:00

fix: max 4 significant digits for speed (#5100)

This commit is contained in:
Cœur 2023-03-02 01:33:17 +08:00 committed by GitHub
parent 63653b4831
commit 03a23cf797
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -160,24 +160,24 @@
+ (NSString*)stringForSpeed:(CGFloat)speed kb:(NSString*)kb mb:(NSString*)mb gb:(NSString*)gb + (NSString*)stringForSpeed:(CGFloat)speed kb:(NSString*)kb mb:(NSString*)mb gb:(NSString*)gb
{ {
if (speed <= 999.95) //0.0 KB/s to 999.9 KB/s if (speed < 999.95) // 0.0 KB/s to 999.9 KB/s
{ {
return [NSString localizedStringWithFormat:@"%.1f %@", speed, kb]; return [NSString localizedStringWithFormat:@"%.1f %@", speed, kb];
} }
speed /= 1000.0; speed /= 1000.0;
if (speed <= 99.995) //1.00 MB/s to 99.99 MB/s if (speed < 99.995) // 1.00 MB/s to 99.99 MB/s
{ {
return [NSString localizedStringWithFormat:@"%.2f %@", speed, mb]; return [NSString localizedStringWithFormat:@"%.2f %@", speed, mb];
} }
else if (speed <= 999.95) //100.0 MB/s to 999.9 MB/s else if (speed < 999.95) // 100.0 MB/s to 999.9 MB/s
{ {
return [NSString localizedStringWithFormat:@"%.1f %@", speed, mb]; return [NSString localizedStringWithFormat:@"%.1f %@", speed, mb];
} }
else //insane speeds else // insane speeds
{ {
return [NSString localizedStringWithFormat:@"%.2f %@", (speed / 1000.0), gb]; return [NSString localizedStringWithFormat:@"%.2f %@", speed / 1000.0, gb];
} }
} }