On Sun, May 14, 2017 at 19:48 +0000, Carl Mascott wrote: > I have a suggestion RE your pftop.c patch. You are rounding > multiple times, after each scale operation. This is known as > rounding the intermediate results of a calculation and degrades > accuracy. If you're not familiar with the issue do a Google search > on rounding intermediate. >
I round only once, that's what I've explained in my mail. > I suggest assigning the pf rate to an unsigned long and multiplying by 10. > This makes the LSD a guard digit. > After all scaling, round once (if guard digit >= 5 then add 10). > Yes, this may require one more scaling operation if it rounds up to 6 digits > (including guard digit). > At the very end divide by 10. > Note: This is essentially fixed point arithmetic with one decimal digit. > > I modified pftop.c v1.37 to do this earlier today. > It was kind of tricky. > I need to see if it still looks OK on Tuesday (I'm busy Monday). > Let me know if you want a patch then. > I won't have actually tested it, though, so it's highly likely to have bugs. > You might be better off writing your own (and then perhaps comparing to mine). > > RE my email client: It's Yahoo webmail -- nothing I can do about it. > pftop in systat can only display 4 digits and 1 unit symbol so you can't display all digits of your bandwidth spec. But please by all means, send your diff and I'll take a look at it.