From: "Edd Dawson" Newsgroups: comp.os.msdos.djgpp References: <3DF984EB DOT 8010102 AT earthlink DOT net> Subject: re: (solved) Lines: 61 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Message-ID: Date: Fri, 13 Dec 2002 14:57:31 -0000 NNTP-Posting-Host: 80.192.26.95 X-Complaints-To: abuse AT blueyonder DOT co DOT uk X-Trace: news-binary.blueyonder.co.uk 1039791208 80.192.26.95 (Fri, 13 Dec 2002 14:53:28 GMT) NNTP-Posting-Date: Fri, 13 Dec 2002 14:53:28 GMT Organization: blueyonder (post doesn't reflect views of blueyonder) To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Please read my previous reply. Problem is solved. Simple slip up on my part. Edd "Martin Ambuhl" wrote in message news:3DF984EB DOT 8010102 AT earthlink DOT net... > Edd Dawson wrote: > > Hi, > > > > I came across an unexpected result when executing a program I'm writing. > > After tracking it down in the source, I wrote a few lines of test code and > > found that a simple evaluation of an inequality was failing. > > Here is the small chunk of test code from the program I am writing: > > > > //test code starts here > > > > printf("\nRPP = %d\n", raysperpixel); > > if(raysperpixel < 1) > > printf("%d is less than 1\n", raysperpixel); > > else > > printf("%d is greater than or equal to 1\n", raysperpixel); > > > > //test code ends here > > > > raysperpixel is an int (i.e its defined properly). > > Here is the corresponding output: > > > > RPP = -35 > > -35 is greater than or equal to 1 > > I don't believe you. Here is a compilable version of your code, together > with the output: > > #include > > int main(void) > { > int raysperpixel = -35; > printf("\nRPP = %d\n", raysperpixel); > if (raysperpixel < 1) > printf("%d is less than 1\n", raysperpixel); > else > printf("%d is greater than or equal to 1\n", raysperpixel); > return 0; > } > > > RPP = -35 > -35 is less than 1 > > > > > This makes about as much sense as the program's output! Can anyone help me > > out? I'm pretty sure it's a bug, > > I'm pretty sure you've got some error in your code. >