On Tue, Nov 15, 2011 at 09:18:54AM -0800, Justin Pettit wrote:
> On Nov 15, 2011, at 9:15 AM, Ben Pfaff wrote:
> 
> > On Tue, Nov 15, 2011 at 01:48:50AM -0800, Justin Pettit wrote:
> >> static int
> >> ms_to_timer_remainder(int ms)
> >> {
> >> -    return ms * 0x100 % 1000;
> >> +    return (ms * 0x100 % 1000) / 0x100;
> >> }
> > 
> > I think that this actually loses precision in the other direction.
> > However, in a couple of quick calculations it looks like it is
> > probably accurate enough.
> 
> Do you have a suggestion?  It didn't seem optimal last night, but I
> wasn't coming up with anything better at the time.

How about dropping that function entirely, then changing:
    stp->elapsed_remainder = ms_to_timer_remainder(ms);
to:
    stp->elapsed_remainder = ms - timer_to_ms(elapsed);

I believe that will be accurate.
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to