Mail Archives: djgpp/2001/05/22/15:22:29
Scott Sinclair <scott DOT sinclair AT umgeni DOT co DOT za> wrote:
> //////////////////////////////
> double x, y;
> y = some_sensibly_small_number;
> x = exp(y);
> /////////////////////////////
> does NOT set x equal to e^y ????
Of course it doesn't. As given, it won't even compile, since it's
incomplete (no enclosing function for the statements, no main()
function.
The real problem would have been revealed right away if only you had
allowed GCC to help you. 'gcc -Wall -W -O2 -g' would have warned you
about an implicit declaration of function 'exp'. Which in turn
probably occurs because you forgot to
#include <math.h>
I'll leave it as an exercise to you to find out what the exact
consequences of this omission would be, and how that caused the badly
incorrect result you got from your program.
--
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.
- Raw text -