vmstat: precision issues in unitConvert()
Fix conversion errors due to precision issues in function unitConvert For example: unitConvert(98720620) will return 98720624, not 98720620. Because we do (unsigned long)(float)98720620 in function unitConvert and this is wrong! We should do (unsigned long)(double)98720620 here. Signed-off-by: Craig Small <csmall@dropbear.xyz> References: procps-ng/procps!75
This commit is contained in:
parent
68e2c0fc53
commit
0a5ccbdd42
1
NEWS
1
NEWS
@ -9,6 +9,7 @@ procps-ng-NEXT
|
|||||||
* vmstat: Referesh memory statistics Debian #1027963
|
* vmstat: Referesh memory statistics Debian #1027963
|
||||||
* vmstat: Fix initial si,so,bi,bo,in & cs values issue #15
|
* vmstat: Fix initial si,so,bi,bo,in & cs values issue #15
|
||||||
Debian #668580
|
Debian #668580
|
||||||
|
* vmstat: Fix conversion errors due to precision merge #75
|
||||||
* w: Add --pids option merge #159
|
* w: Add --pids option merge #159
|
||||||
* watch: Pass through beep issue #104
|
* watch: Pass through beep issue #104
|
||||||
* watch: -r option to not re-exec on SIGWINCH merge #125
|
* watch: -r option to not re-exec on SIGWINCH merge #125
|
||||||
|
@ -336,8 +336,8 @@ static void new_header(void)
|
|||||||
|
|
||||||
static unsigned long unitConvert(unsigned long size)
|
static unsigned long unitConvert(unsigned long size)
|
||||||
{
|
{
|
||||||
float cvSize;
|
double cvSize;
|
||||||
cvSize = (float)size / dataUnit * ((statMode == SLABSTAT) ? 1 : 1024);
|
cvSize = (double)size / dataUnit * ((statMode == SLABSTAT) ? 1 : 1024);
|
||||||
return ((unsigned long)cvSize);
|
return ((unsigned long)cvSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user