Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C Moderated > why nan and inf...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 11 Topic 947 of 1145
Post > Topic >>

why nan and infs evaluate to true when used as if condition values?

by Ganny <sgganesh@[EMAIL PROTECTED] > May 15, 2007 at 04:06 PM

#include <stdio.h>
int main() {
    int a = 0;
    if (1.0/0.0)
         printf("result was true");
    else
        printf("result was false");
}

I get "result was true" in the compilers i tried - Is this the right
behaviour expected? shouldn't nans and infs treated as false?

thanks!
-ganesh
-- 
comp.lang.c.moderated - moderation address: clcm@[EMAIL PROTECTED]
 -- you must
have an appropriate newsgroups line in your header for your mail to be
seen,
or the newsgroup name in square brackets in the subject line.  Sorry.
 




 11 Posts in Topic:
why nan and infs evaluate to true when used as if condition valu
Ganny <sgganesh@[EMAIL  2007-05-15 16:06:41 
Re: why nan and infs evaluate to true when used as if condition
=?ISO-8859-1?Q?Hans-Bernh  2007-05-17 06:16:22 
Re: why nan and infs evaluate to true when used as if condition
Michael Tiomkin <tmk@[  2007-05-17 06:16:32 
Re: why nan and infs evaluate to true when used as if condition
jgd@[EMAIL PROTECTED] (J  2007-05-17 06:16:41 
Re: why nan and infs evaluate to true when used as if condition
lawrence.jones@[EMAIL PRO  2007-05-17 06:16:27 
Re: why nan and infs evaluate to true when used as if condition
Keith Thompson <kst-u@  2007-05-17 06:16:46 
Re: why nan and infs evaluate to true when used as if condition
jg <jgu222@[EMAIL PROT  2007-05-17 06:16:55 
Re: why nan and infs evaluate to true when used as if condition
WillerZ <newsreplies@[  2007-05-17 06:16:59 
Re: why nan and infs evaluate to true when used as if condition
Jack Klein <jackklein@  2007-05-17 06:17:09 
Re: why nan and infs evaluate to true when used as if condition
"Douglas A. Gwyn&quo  2007-05-17 06:17:38 
Re: why nan and infs evaluate to true when used as if condition
Francis Glassborow <fr  2007-05-17 06:17:49 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Sep 7 7:57:01 CDT 2008.