-
-
Notifications
You must be signed in to change notification settings - Fork 274
Open
Description
To reproduce the error use pattern
import type.size;
type::Size128 size @ 0x0;on two inputs. First on
00 00 00 00 00 00 00 10 00 00 00 00 00 00 00 00this return 1 Eib which is correct.
then change the input to
00 00 00 00 00 00 00 00 40 00 00 00 00 00 00 00and the result is incorrectly set to 1 EiB again instead of 1024 EiB.
The error is dies to this line in the code for the formatter
while (sizeFloat >= 1024 && i <= 6) {which should really be
while (sizeFloat >= 1024 && i < 6) {I can submit a PR with this fix or I also have rewritten the formatter in a shorter version as:
u32 i = std::math::min(u32(std::math::log2(size))/10,6);
double sizeFloat = double(size)/double(1 << 10 * i);
str sizeStr[7] = {"Byte", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB"};
str formatString = (i!=0) ? "{:.3f} {}" : "{} {}";
str result = std::format(formatString, sizeFloat, sizeStr[i]);
if (i==0 && sizeFloat != 1.0)
result += 's';
return result;that can also be used instead.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels