df
rundet immer die lesbare Ausgabe ( -h
und -H
) ab.
Aus dem Quellcode des coreutils-Pakets werden lib/human.h
zahlreiche Optionen für die human_readable
Rundungsfunktion, die Einheitenumrechnung usw. aufgeführt:
/* Options for human_readable. */ enum { /* Unless otherwise specified these options may be ORed together. */ /* The following three options are mutually exclusive. */ /* Round to plus infinity (default). */ human_ceiling = 0, /* Round to nearest, ties to even. */ human_round_to_nearest = 1, /* Round to minus infinity. */ human_floor = 2, ...
Beachten Sie den Kommentar: Round to plus infinity (default).
Die eigentliche Rundung geschieht wahrscheinlich in der folgenden Funktion in human.c
, die addiert true
(dh, 1
wenn keine andere oben gezeigte Rundungsoption gesetzt ist (wird nicht gesetzt, sondern -h
nur gesetzt) human_autoscale | human_SI | human_base_1024
, was zur automatischen Skalierung mit 1024 als Einheitsinkrement führt und das Suffix des SI-Stils druckt. dh G
) und der Wert ist keine ganze Zahl:
static long double adjust_value (int inexact_style, long double value) { /* Do not use the floorl or ceill functions, as that would mean checking for their presence and possibly linking with the standard math library, which is a porting pain. So leave the value alone if it is too large to easily round. */ if (inexact_style != human_round_to_nearest && value < UINTMAX_MAX) { uintmax_t u = value; value = u + (inexact_style == human_ceiling && u != value); } return value; }