OK, I was indeed missing something. Thanks, Theo and Mike. I think I see another very minor problem, though. Let the pf BW be 9,999,999. Shift right 3 digits (divide by 1000) : yields 9,999K. (If we were doing floating point arithmetic, would yield 9,999.999K.) You (Mike) don't round this, presumably to avoid overflow to 10,000 (5 digits). However, since (i < 3) it could have been rounded and scaled again, to 10M. Slightly more accurate but not a big deal.
-------------------------------------------- On Sun, 5/14/17, Theo Buehler <t...@math.ethz.ch> wrote: Subject: Re: pf queue definition: bandwidth resolution problem To: tech@openbsd.org Date: Sunday, May 14, 2017, 4:35 PM On Sun, May 14, 2017 at 08:29:18PM +0000, Carl Mascott wrote: > It looks to me like you are rounding on each iteration of the for-loop: > > + for (i = 0; rate > 9999 && i <= 3; i++) { > + rtmp = rate / 1000; > + if (rtmp < 9999) This is only true in the last iteration. > + rtmp += (rate % 1000) / 500; > + rate = rtmp; > + } > > Am I missing something?