Path: chuka.playstation.co.uk!scea!greg_labrec@interactive.sony.com From: Joshua Meeds Newsgroups: scee.yaroze.programming.gnu_compiler Subject: Re: printf works, code doesn't Date: Wed, 15 Apr 1998 19:42:28 -0700 Organization: SCEA News Server Lines: 51 Message-ID: <35357014.E195CEDC@sinclair.net> References: <3532D4BA.49B30CA9@sinclair.net> <3534730B.2417@127.0.0.1> NNTP-Posting-Host: dreamer.sincom.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.04 [en] (Win95; I) Well, that was the actual code, but that line wasn't remmed out (I think it was my newsgroup poster that messed it up). You know what fixed the problem? I had to type cast the equation as a double, like so: Fun=(double)(((Y2-Y1) / (X2-X1)); Majik wrote: > > > double Slope(int a,int b) > > { > > u_long X1,Y1,X2,Y2; > > double Fun; > > > > X1=Dude[a].position.vx; > > Y1=Dude[a].position.vz; > > X2=Dude[b].position.vx; > > Y2=Dude[b].position.vz; > > printf2("\n%d / %d = %e -- ",Y2-Y1,X2-X1, (Y2-Y1) / (X2-X1)); > > //printf2 = printf that supports %e Fun=((Y2-Y1) / (X2-X1)); > > printf("%e",Fun); > > > > return (Fun); // Used to be return ((Y2-Y1) / (X2-X1)); - Same thing happened > > } > > Is this the actaul code you are using? I only ask because 'Fun' isnt > assigned any > value, it is hidden by the // comment, what happens if you do > > //printf2 = printf that supports %e > Fun=((Y2-Y1) / (X2-X1)); > > instead of > > > //printf2 = printf that supports %e Fun=((Y2-Y1) / (X2-X1)); > > or is it just my mailreader that has screwed that bit up, sorry if I've > been patronising. > > M. > > -- > -- Majik - Owner/Curator of the Sinclair Microcomputer Museum > -- Spod in a suitcase - ' Have Compiler, will travel ' > -- http://mudhole.spodnet.uk.com/~majik/ > -- -- - Dreamwriter Dragon dreamer@sinclair.net -==UDIC==-