delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/05/22/15:22:29

From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: exp() doesn't work !
Date: 22 May 2001 17:43:01 GMT
Organization: Aachen University of Technology (RWTH)
Lines: 29
Message-ID: <9ee8f5$bru$1@nets3.rz.RWTH-Aachen.DE>
References: <F6E7432DD437D511AD92009027C3AAC466B52F AT headoffice DOT umgeni DOT co DOT za>
NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de
X-Trace: nets3.rz.RWTH-Aachen.DE 990553381 12158 137.226.32.75 (22 May 2001 17:43:01 GMT)
X-Complaints-To: abuse AT rwth-aachen DOT de
NNTP-Posting-Date: 22 May 2001 17:43:01 GMT
Originator: broeker@
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019