mirror of
https://github.com/pikami/slstatus.git
synced 2024-12-05 01:35:41 +00:00
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.
This commit is contained in:
parent
422cadfd5f
commit
68a3902dc5
@ -26,8 +26,8 @@
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return oldrxbytes ? fmt_scaled((rxbytes - oldrxbytes) /
|
return oldrxbytes ? fmt_scaled((rxbytes - oldrxbytes) *
|
||||||
interval * 1000) : NULL;
|
1000 / interval) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
@ -49,8 +49,8 @@
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return oldtxbytes ? fmt_scaled((txbytes - oldtxbytes) /
|
return oldtxbytes ? fmt_scaled((txbytes - oldtxbytes) *
|
||||||
interval * 1000) : NULL;
|
1000 / interval) : NULL;
|
||||||
}
|
}
|
||||||
#elif defined(__OpenBSD__)
|
#elif defined(__OpenBSD__)
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -88,8 +88,8 @@
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return oldrxbytes ? fmt_scaled((rxbytes - oldrxbytes) /
|
return oldrxbytes ? fmt_scaled((rxbytes - oldrxbytes) *
|
||||||
interval * 1000) : NULL;
|
1000 / interval) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
@ -121,7 +121,7 @@
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return oldtxbytes ? fmt_scaled((txbytes - oldtxbytes) /
|
return oldtxbytes ? fmt_scaled((txbytes - oldtxbytes) *
|
||||||
interval * 1000) : NULL;
|
1000 / interval) : NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user