Download GNUMCSim: A Monte Carlo Simulation Program

Transcript
Chapter 7: Common Pitfalls
53
7 Common Pitfalls
The following mistakes are particularly easy to make, and sometimes hard to notice, or
understand at first.
• Forgetting about type-related arithmetics in C: ‘1000/882’ gives ‘1’ since it is interpreted as an integer division by the compiler. To get a floating-point (usual) division
use ‘1000./882.’.
• Forgetting a semi-colon (’;’) at the end of statements: the error is usually detected at
the following line(s) where in fact nothing may be wrong.