SV: [Icc-avr] Calculations

Bengt Ragnemalm benra at imt.liu.se
Tue Jan 8 23:32:05 PST 2008


This was only sent to Andy so I resend it here to end the subject. /B

 

 Oups, very embarrassing, I actually missed the -1.

 

Thanks Andy. Sorry to all for stupid question.

 

I can only blame my mistake that I had a more complex calculation to start
with and therefore missed the -1.

 

/Bengt

 

> -----Ursprungligt meddelande-----

> Från: Andy Syms [mailto:asyms at technosoft.co.uk]

> Skickat: den 7 januari 2008 16:10

> Till: benra at imt.liu.se; Discussion list for ICCAVR and ICCtiny Users. 

> You do NOT need tosubscribeto icc-announce if you are a member of this.

> Ämne: RE: [Icc-avr] Calculations

> 

> > temp2 = 0/(16L*baudrate)-1;    // Results into 65535

> 

> > I guess that the last calculation error is because of some rounding 

> > problem but obviously the correct answer is 0.

> 

> No.  0 - 1 is -1 which, if temp2 is an unsigned int would be 

> represented as 0xffff, ie 65535.

> 

> Don't forget that division takes precedence over subtraction.

> 

> Andy

> 

> --

> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

> >>

> >>  Andy Syms        Technosoft Systems Ltd

> >>

> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

> 

> 

 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://dragonsgate.net/pipermail/icc-avr/attachments/20080109/9de0d375/attachment.html


More information about the Icc-avr mailing list