소스 검색

Increase precision in netspeeds.c

First dividing by interval before multiplying with 1000 decreases the
precision by +-(interval - 1) * 1000, as interval arithmetic always
applies the Gauß-function to the result.

This is not necessary and simply reordering the operations mitigates
this.
master
Laslo Hunhold 6 년 전
committed by Aaron Marcher
부모
커밋
68a3902dc5
1개의 변경된 파일8개의 추가작업 그리고 8개의 파일을 삭제
  1. +8
    -8
      components/netspeeds.c

+ 8
- 8
components/netspeeds.c 파일 보기

@@ -26,8 +26,8 @@
return NULL;
}

return oldrxbytes ? fmt_scaled((rxbytes - oldrxbytes) /
interval * 1000) : NULL;
return oldrxbytes ? fmt_scaled((rxbytes - oldrxbytes) *
1000 / interval) : NULL;
}

const char *
@@ -49,8 +49,8 @@
return NULL;
}

return oldtxbytes ? fmt_scaled((txbytes - oldtxbytes) /
interval * 1000) : NULL;
return oldtxbytes ? fmt_scaled((txbytes - oldtxbytes) *
1000 / interval) : NULL;
}
#elif defined(__OpenBSD__)
#include <string.h>
@@ -88,8 +88,8 @@
return NULL;
}

return oldrxbytes ? fmt_scaled((rxbytes - oldrxbytes) /
interval * 1000) : NULL;
return oldrxbytes ? fmt_scaled((rxbytes - oldrxbytes) *
1000 / interval) : NULL;
}

const char *
@@ -121,7 +121,7 @@
return NULL;
}

return oldtxbytes ? fmt_scaled((txbytes - oldtxbytes) /
interval * 1000) : NULL;
return oldtxbytes ? fmt_scaled((txbytes - oldtxbytes) *
1000 / interval) : NULL;
}
#endif

불러오는 중...
취소
저장