[Icc-avr] Calculations

Bengt Ragnemalm benra at imt.liu.se
Mon Jan 7 06:29:11 PST 2008


Hi!

 

I have spent some of my spare time during Christmas solving some strange
problems I have had with a design. My problems was something completely
different but I ended up with this:

 

- I have found a calculation that may be a compiler error.

 

This is my test code, baudrate is 38400:

 

#define F_CPU 7372800


temp2 = F_CPU/(16L*baudrate)-1;    // Normal calculation, result OK
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.

 

/Bengt

________________________________________________________________

Bengt Ragnemalm                        Tel +46 13 22 24 97

Research engineer                                       FAX: +46 13 10 19 02

Linköpings Universitet
<mailto:bengt.ragnemalm at imt.liu.se> mailto:bengt.ragnemalm at imt.liu.se

Inst. för Medicinsk Teknik Internet:         <http://www.imt.liu.se/>
http://www.imt.liu.se

S-581 85 Linköping SWEDEN

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://dragonsgate.net/pipermail/icc-avr/attachments/20080107/163af97b/attachment.html


More information about the Icc-avr mailing list