I was using pacman to update my Manjaro system on the commandline. I noticed that the progress uses KiB to measure the amount of downloaded data. This changes to MiB after it reaches 2048 KiB (most probably; the time switching from the previous to the next is very small and not completely verifiable by observation). My question is this: What is the reasoning of changing it to MiB only at 2048 KiB and not 1024 KiB? It could very well have been presented as 1 MiB.

  • @DavidPostill, it would help if you gave some pointers (specific; not a template) on how I can make the question better rather than simply putting it on hold. – Gaurav Joseph Jan 2 at 9:59
  • 2
    Short of obvious technical reasons, questions regarding decisions about why a program works a certain way are likely to attract speculation. However, in the case of open source software, they can be definitively answered by eg code comment explaining why, commit message, mailing list discussion, IRC log, or statement from developer (last one not exclusive to OS software either!). – bertieb Jan 2 at 10:30

What is the reasoning of changing it to MiB only at 2048 KiB and not 1024 KiB?

The developers decided to code it that way:

/** Converts sizes in bytes into human readable units.
 * @param bytes the size in bytes
 * @param target_unit '\0' or a short label. If equal to one of the short unit
 * labels ('B', 'K', ...) bytes is converted to target_unit; if '\0', the first
 * unit which will bring the value to below a threshold of 2048 will be chosen.
 * @param precision number of decimal places, ensures -0.00 gets rounded to
 * 0.00; -1 if no rounding desired
 * @param label will be set to the appropriate unit label
 * @return the size in the appropriate unit
double humanize_size(off_t bytes, const char target_unit, int precision,
        const char **label)
    static const char *labels[] = {"B", "KiB", "MiB", "GiB",
        "TiB", "PiB", "EiB", "ZiB", "YiB"};
    static const int unitcount = ARRAYSIZE(labels);

    double val = (double)bytes;
    int index;

    for(index = 0; index < unitcount - 1; index++) {
        if(target_unit != '\0' && labels[index][0] == target_unit) {
        } else if(target_unit == '\0' && val <= 2048.0 && val >= -2048.0) {
        val /= 1024.0;

    if(label) {
        *label = labels[index];

    /* do not display negative zeroes */
    if(precision >= 0 && val < 0.0 &&
            val > (-0.5 / simple_pow(10, precision))) {
        val = 0.0;

    return val;

Source util.c\pacman\src - pacman.git - The official pacman repository

It could very well have been presented as 1 MiB.

It is an open source project. You can add a feature request to change the behavior or clone the project and change it yourself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.