free: Update tests and fix for previous patch

The previous two patches updated free, but needed a tweak and the tests
also needed to be updated. I've hand-calculated the results using bc and
both the testsuite and bc results equal what free prints out.

References:
 commit 9365be7633
 procps-ng/procps#45
This commit is contained in:
Craig Small
2018-01-13 16:09:54 +11:00
parent 9365be7633
commit e82dd07b3b
3 changed files with 6 additions and 5 deletions

2
free.c
View File

@ -133,7 +133,7 @@ static const char *scale_size(unsigned long size, int flags, struct commandline_
if (args.exponent > 1) {
/* In desired scale. */
snprintf(buf, sizeof(buf), "%ld",
(long int)((size / 1024) * base / power(base, args.exponent - 2))
(long int)((size * 1024) / power(base, args.exponent-1))
);
return buf;
}