On Mon, Feb 8, 2010 at 11:35 AM, Miklos Maroti <[email protected]> wrote: > Janos, Andreas and David, > > From scale.h the scale32(x,a,b) call calculates x*a/b with fixed point > arithmetic without overflow. The offset was added to help rounding, > but it was not implemented correctly. If you want to calculate x/b, > then it makes sense to calculate it as (x + b>>1)/b to get the > rounding effect. However, this is NOT needed here since a/b should be > close to 1 and in fact the added offset should be a/(2*b). So I think > this is clearly a bug and should be removed! > > Andras, can you please change the code to > > async command uint32_t Atm128Calibrate.calibrateMicro(uint32_t n) { > return scale32(n, cycles, MAGIC); > } > > async command uint32_t Atm128Calibrate.actualMicro(uint32_t n) { > return scale32(n, MAGIC, cycles); > } > > and rerun your experiments? David, can you confirm that this is indeed a bug?
Yes, your summary is correct (except that the ideal offset would be b/2a, which would be ~1/2). It might be worth forcing the result to be at least 1 as well - do we want calibrateMicro(1)/actualMicro(1) to sometimes give 0? David _______________________________________________ Tinyos-help mailing list [email protected] https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
