| ... | @@ -559,14 +559,19 @@ pub fn formatBytes( | ... | @@ -559,14 +559,19 @@ pub fn formatBytes( |
| 559 | return output(context, "0B"); | 559 | return output(context, "0B"); |
| 560 | } | 560 | } |
| 561 | | 561 | |
| 562 | const mags = " KMGTPEZY"; | 562 | const mags_si = " kMGTPEZY"; |
| | 563 | const mags_iec = " KMGTPEZY"; |
| 563 | const magnitude = switch (radix) { | 564 | const magnitude = switch (radix) { |
| 564 | 1000 => math.min(math.log2(value) / comptime math.log2(1000), mags.len - 1), | 565 | 1000 => math.min(math.log2(value) / comptime math.log2(1000), mags_si.len - 1), |
| 565 | 1024 => math.min(math.log2(value) / 10, mags.len - 1), | 566 | 1024 => math.min(math.log2(value) / 10, mags_iec.len - 1), |
| 566 | else => unreachable, | 567 | else => unreachable, |
| 567 | }; | 568 | }; |
| 568 | const new_value = f64(value) / math.pow(f64, f64(radix), f64(magnitude)); | 569 | const new_value = f64(value) / math.pow(f64, f64(radix), f64(magnitude)); |
| 569 | const suffix = mags[magnitude]; | 570 | const suffix = switch (radix) { |
| | 571 | 1000 => mags_si[magnitude], |
| | 572 | 1024 => mags_iec[magnitude], |
| | 573 | else => unreachable, |
| | 574 | }; |
| 570 | | 575 | |
| 571 | try formatFloatDecimal(new_value, width, context, Errors, output); | 576 | try formatFloatDecimal(new_value, width, context, Errors, output); |
| 572 | | 577 | |