Guys,
Is it guaranteed that FALSE will always expand to value 0 and TRUE
to some non zero value.
if (TRUE) /* will this always be successful */
if (FALSE) /* will this always fail */
thanks...
|
|
0
|
|
|
|
Reply
|
junky_fellow (377)
|
8/11/2009 4:56:00 PM |
|
"junky_fellow@yahoo.co.in" <junky_fellow@yahoo.co.in> writes:
> Is it guaranteed that FALSE will always expand to value 0 and TRUE
> to some non zero value.
>
> if (TRUE) /* will this always be successful */
>
> if (FALSE) /* will this always fail */
Only if you define them that way.
The identifiers TRUE and FALSE are not defined in the standard C
language or library.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
|
|
0
|
|
|
|
Reply
|
kst-u (21484)
|
8/11/2009 5:08:05 PM
|
|
On Aug 11, 10:08=A0pm, Keith Thompson <ks...@mib.org> wrote:
> "junky_fel...@yahoo.co.in" <junky_fel...@yahoo.co.in> writes:
> > =A0 =A0Is it guaranteed that FALSE will always expand to value 0 and TR=
UE
> > to some non zero value.
>
> > =A0 =A0if (TRUE) =A0/* will this always be successful */
>
> > =A0 =A0if (FALSE) =A0/* will this always fail */
>
> Only if you define them that way.
>
> The identifiers TRUE and FALSE are not defined in the standard C
> language or library.
>
stdbool.h has them though(in small letters), doesn't it?
"true" and "false"
|
|
0
|
|
|
|
Reply
|
harsha.dsh (50)
|
8/12/2009 2:43:12 AM
|
|
On Aug 12, 10:43=A0am, dsriharsha <harsha....@gmail.com> wrote:
> On Aug 11, 10:08=A0pm, Keith Thompson <ks...@mib.org> wrote:
>
> > "junky_fel...@yahoo.co.in" <junky_fel...@yahoo.co.in> writes:
> > > =A0 =A0Is it guaranteed that FALSE will always expand to value 0 and =
TRUE
> > > to some non zero value.
>
> > > =A0 =A0if (TRUE) =A0/* will this always be successful */
>
> > > =A0 =A0if (FALSE) =A0/* will this always fail */
>
> > Only if you define them that way.
>
> > The identifiers TRUE and FALSE are not defined in the standard C
> > language or library.
>
> stdbool.h has them though(in small letters), doesn't it?
> "true" and "false"
True. It's case sensitive, so names in different cases ain't identical.
|
|
0
|
|
|
|
Reply
|
lovecreatesbeauty (723)
|
8/12/2009 5:41:09 AM
|
|
dsriharsha wrote:
> On Aug 11, 10:08 pm, Keith Thompson <ks...@mib.org> wrote:
>> "junky_fel...@yahoo.co.in" <junky_fel...@yahoo.co.in> writes:
>>> Is it guaranteed that FALSE will always expand to value 0 and TRUE
>>> to some non zero value.
>>> if (TRUE) /* will this always be successful */
>>> if (FALSE) /* will this always fail */
>> Only if you define them that way.
>>
>> The identifiers TRUE and FALSE are not defined in the standard C
>> language or library.
>>
>
> stdbool.h has them though(in small letters), doesn't it?
> "true" and "false"
Yes, and since C is case sensitive, that's a completely different issue.
stdbool.h is required to #define false so that it "expands to the
integer constant 0" (7.16p3).
|
|
0
|
|
|
|
Reply
|
jameskuyper (5171)
|
8/12/2009 9:51:54 AM
|
|
On 12 Aug, 03:43, dsriharsha <harsha....@gmail.com> wrote:
> On Aug 11, 10:08=A0pm, Keith Thompson <ks...@mib.org> wrote:
>
> > "junky_fel...@yahoo.co.in" <junky_fel...@yahoo.co.in> writes:
> > > =A0 =A0Is it guaranteed that FALSE will always expand to value 0 and =
TRUE
> > > to some non zero value.
>
> > > =A0 =A0if (TRUE) =A0/* will this always be successful */
>
> > > =A0 =A0if (FALSE) =A0/* will this always fail */
>
> > Only if you define them that way.
>
> > The identifiers TRUE and FALSE are not defined in the standard C
> > language or library.
>
> stdbool.h has them though(in small letters), doesn't it?
> "true" and "false"
and stdbool is a C99 feature
|
|
0
|
|
|
|
Reply
|
nick_keighley_nospam (4574)
|
8/12/2009 11:42:06 AM
|
|
On 11 Aug, 17:56, "junky_fel...@yahoo.co.in"
<junky_fel...@yahoo.co.in> wrote:
> =A0 =A0Is it guaranteed that FALSE will always expand to value 0 and TRUE
> to some non zero value.
no, but zero is treated as false and any non-zero value is treated as
true.
> =A0 =A0if (TRUE) =A0/* will this always be successful */
>
> =A0 =A0if (FALSE) =A0/* will this always fail */
depends how you define them
|
|
0
|
|
|
|
Reply
|
nick_keighley_nospam (4574)
|
8/12/2009 11:44:41 AM
|
|
On Aug 12, 2:51=A0pm, James Kuyper <jameskuy...@verizon.net> wrote:
> dsriharsha wrote:
> > On Aug 11, 10:08 pm, Keith Thompson <ks...@mib.org> wrote:
> >> "junky_fel...@yahoo.co.in" <junky_fel...@yahoo.co.in> writes:
> >>> =A0 =A0Is it guaranteed that FALSE will always expand to value 0 and =
TRUE
> >>> to some non zero value.
> >>> =A0 =A0if (TRUE) =A0/* will this always be successful */
> >>> =A0 =A0if (FALSE) =A0/* will this always fail */
> >> Only if you define them that way.
>
> >> The identifiers TRUE and FALSE are not defined in the standard C
> >> language or library.
>
> > stdbool.h has them though(in small letters), doesn't it?
> > "true" and "false"
>
> Yes, and since C is case sensitive, that's a completely different issue.
> =A0 stdbool.h is required to #define false so that it "expands to the
> integer constant 0" (7.16p3).
Well yes.. C is case sensitive and everything.. I was just mentioning
that something to that effect(what the OP uses) does exist in C.
|
|
0
|
|
|
|
Reply
|
harsha.dsh (50)
|
8/12/2009 4:35:20 PM
|
|
On Aug 12, 4:42=A0pm, Nick Keighley <nick_keighley_nos...@hotmail.com>
wrote:
> On 12 Aug, 03:43, dsriharsha <harsha....@gmail.com> wrote:
>
>
>
> > On Aug 11, 10:08=A0pm, Keith Thompson <ks...@mib.org> wrote:
>
> > > "junky_fel...@yahoo.co.in" <junky_fel...@yahoo.co.in> writes:
> > > > =A0 =A0Is it guaranteed that FALSE will always expand to value 0 an=
d TRUE
> > > > to some non zero value.
>
> > > > =A0 =A0if (TRUE) =A0/* will this always be successful */
>
> > > > =A0 =A0if (FALSE) =A0/* will this always fail */
>
> > > Only if you define them that way.
>
> > > The identifiers TRUE and FALSE are not defined in the standard C
> > > language or library.
>
> > stdbool.h has them though(in small letters), doesn't it?
> > "true" and "false"
>
> and stdbool is a C99 feature
point being?
|
|
0
|
|
|
|
Reply
|
harsha.dsh (50)
|
8/12/2009 4:35:56 PM
|
|
dsriharsha <harsha.dsh@gmail.com> writes:
> On Aug 12, 4:42�pm, Nick Keighley <nick_keighley_nos...@hotmail.com>
> wrote:
>> On 12 Aug, 03:43, dsriharsha <harsha....@gmail.com> wrote:
>> > On Aug 11, 10:08�pm, Keith Thompson <ks...@mib.org> wrote:
>> > > "junky_fel...@yahoo.co.in" <junky_fel...@yahoo.co.in> writes:
>> > > > � �Is it guaranteed that FALSE will always expand to value 0 and TRUE
>> > > > to some non zero value.
>>
>> > > > � �if (TRUE) �/* will this always be successful */
>>
>> > > > � �if (FALSE) �/* will this always fail */
>>
>> > > Only if you define them that way.
>>
>> > > The identifiers TRUE and FALSE are not defined in the standard C
>> > > language or library.
>>
>> > stdbool.h has them though(in small letters), doesn't it?
>> > "true" and "false"
>>
>> and stdbool is a C99 feature
>
> point being?
The point being that most C implementations do not fully support C99,
so code that uses <stdbool.h> may not be 100% portable.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
|
|
0
|
|
|
|
Reply
|
kst-u (21484)
|
8/12/2009 6:05:03 PM
|
|
Keith Thompson <kst-u@mib.org> writes:
> dsriharsha <harsha.dsh@gmail.com> writes:
>> On Aug 12, 4:42 pm, Nick Keighley <nick_keighley_nos...@hotmail.com>
>> wrote:
>>> On 12 Aug, 03:43, dsriharsha <harsha....@gmail.com> wrote:
>>> > On Aug 11, 10:08 pm, Keith Thompson <ks...@mib.org> wrote:
>>> > > "junky_fel...@yahoo.co.in" <junky_fel...@yahoo.co.in> writes:
>>> > > > Is it guaranteed that FALSE will always expand to value 0 and TRUE
>>> > > > to some non zero value.
>>>
>>> > > > if (TRUE) /* will this always be successful */
>>>
>>> > > > if (FALSE) /* will this always fail */
>>>
>>> > > Only if you define them that way.
>>>
>>> > > The identifiers TRUE and FALSE are not defined in the standard C
>>> > > language or library.
>>>
>>> > stdbool.h has them though(in small letters), doesn't it?
>>> > "true" and "false"
>>>
>>> and stdbool is a C99 feature
>>
>> point being?
>
> The point being that most C implementations do not fully support C99,
> so code that uses <stdbool.h> may not be 100% portable.
They don't need to fully support C99 in order to support <stdbool.h>,
in fact, believe it or not, they only need to support the stdbool
subset of C99 in order to support it.
Phil
--
If GML was an infant, SGML is the bright youngster far exceeds
expectations and made its parents too proud, but XML is the
drug-addicted gang member who had committed his first murder
before he had sex, which was rape. -- Erik Naggum (1965-2009)
|
|
0
|
|
|
|
Reply
|
thefatphil_demunged (1558)
|
8/12/2009 10:59:29 PM
|
|
Phil Carmody <thefatphil_demunged@yahoo.co.uk> writes:
> Keith Thompson <kst-u@mib.org> writes:
>> dsriharsha <harsha.dsh@gmail.com> writes:
>>> On Aug 12, 4:42�pm, Nick Keighley <nick_keighley_nos...@hotmail.com>
>>> wrote:
>>>> On 12 Aug, 03:43, dsriharsha <harsha....@gmail.com> wrote:
>>>> > On Aug 11, 10:08�pm, Keith Thompson <ks...@mib.org> wrote:
>>>> > > "junky_fel...@yahoo.co.in" <junky_fel...@yahoo.co.in> writes:
>>>> > > > � �Is it guaranteed that FALSE will always expand to value 0 and TRUE
>>>> > > > to some non zero value.
>>>>
>>>> > > > � �if (TRUE) �/* will this always be successful */
>>>>
>>>> > > > � �if (FALSE) �/* will this always fail */
>>>>
>>>> > > Only if you define them that way.
>>>>
>>>> > > The identifiers TRUE and FALSE are not defined in the standard C
>>>> > > language or library.
>>>>
>>>> > stdbool.h has them though(in small letters), doesn't it?
>>>> > "true" and "false"
>>>>
>>>> and stdbool is a C99 feature
>>>
>>> point being?
>>
>> The point being that most C implementations do not fully support C99,
>> so code that uses <stdbool.h> may not be 100% portable.
>
> They don't need to fully support C99 in order to support <stdbool.h>,
> in fact, believe it or not, they only need to support the stdbool
> subset of C99 in order to support it.
That is, of course, correct (assuming "the stdbool subset of C99"
includes the _Bool keyword).
It's also consistent with what I wrote.
(Well, mostly. It's logically possible that all compilers support
<stdbool.h>, even though not all compilers fully support C99.
But I don't believe that's actually the case.)
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
|
|
0
|
|
|
|
Reply
|
kst-u (21484)
|
8/12/2009 11:52:01 PM
|
|
On 13 Aug, 00:52, Keith Thompson <ks...@mib.org> wrote:
> Phil Carmody <thefatphil_demun...@yahoo.co.uk> writes:
> > Keith Thompson <ks...@mib.org> writes:
> >> dsriharsha <harsha....@gmail.com> writes:
> >>> On Aug 12, 4:42=A0pm, Nick Keighley <nick_keighley_nos...@hotmail.com=
>
> >>>> On 12 Aug, 03:43, dsriharsha <harsha....@gmail.com> wrote:
> >>>> > On Aug 11, 10:08=A0pm, Keith Thompson <ks...@mib.org> wrote:
<snip>
> >>>> > > The identifiers TRUE and FALSE are not defined in the standard C
> >>>> > > language or library.
>
> >>>> > stdbool.h has them though(in small letters), doesn't it?
> >>>> > "true" and "false"
>
> >>>> and stdbool is a C99 feature
>
> >>> point being?
to supply information
> >> The point being that most C implementations do not fully support C99,
> >> so code that uses <stdbool.h> may not be 100% portable.
>
> > They don't need to fully support C99 in order to support <stdbool.h>,
> > in fact, believe it or not, they only need to support the stdbool
> > subset of C99 in order to support it.
>
> That is, of course, correct (assuming "the stdbool subset of C99"
> includes the _Bool keyword).
>
> It's also consistent with what I wrote.
>
> (Well, mostly. =A0It's logically possible that all compilers support
> <stdbool.h>, even though not all compilers fully support C99.
> But I don't believe that's actually the case.)
it isn't. For various reasons people use old compilers.
|
|
0
|
|
|
|
Reply
|
nick_keighley_nospam (4574)
|
8/13/2009 9:13:35 AM
|
|
|
12 Replies
42 Views
(page loaded in 0.128 seconds)
Similiar Articles: compare different rows in differrent var - comp.soft-sys.sas ...After the 1st comparison based on true false, the value will be filled in 2nd row of v2, and then compare 3rd row of v1 to 2nd row of v2 and so on.... V210 EEPROM issue - comp.unix.solaris(along with all the other OBP variables) reverts to it's >> default value of 'false' if the system is rebooted... thats the issue >> I'm having. >> >> Regards ... Establish When Multiple Fields Are True/False -1/0 Yes/No From A ...Establish When Multiple Fields Are True/False -1/0 Yes/No ... multiple flags set for various eventand can be true or false. ... Assign value based on value field in query ... Toggle Button VBA code on Subform - comp.databases.ms-access ...Check Box (Check13) has a default > value of =False, and limits the search to Chicago zip code. My limited > understanding of the code is: If new record or (Check13 ... Best way to code a true/false checkbox? - comp.databases.filemaker ...Currently I am using the following - A value list called 'Binary' with the values 'True', 'False' - A Text field - On the layout, a checkbox set using the 'Binary' value ... for loop combined with if loop.. (new to matlab) - comp.soft-sys ...> In fact this expression will always return false regardless of the value of theta. > > What you need is this: > > if (0 <= theta) && (theta < pi/2) I have a isNumeric function to check a text field is numeric .. I ...So for example !isNaN("0123") evaluates to `true', but parseInt("0123") == parseFloat("0123") evaluates to `false' (because 83 != 123), although the value clearly ... Re: missing numerical values = - infinity? - comp.soft-sys.sas ...The R programming language will return NA for logical statements involving missing values, unless the outcome could conceivably be True or False even with missing ... Implementing delays while thread is running - comp.lang.pascal ...In "C" any non-zero value is True and a value of zero is False, but in Delphi the types must match absolutely or be specifically typecast. javascript:false - comp.lang.javascriptWhere is true and false value documented? - comp.lang.perl.misc ... javascript:false - comp.lang.javascript In Boolean logic, a statement can have two values, true or ... Construct confidence interval for a p-value - comp.soft-sys.matlab ...When I calculate a p-value of, say, a t-test on two sample distributions, that p ... to give a high power under some alternative hypothesis, given a > specified false ... Retrieve selected value from ListBox - comp.databases.ms-access ...I have a ListBox called lstInventory, with two columns, a text value, and the ID ... never shows any item as selected, i.e. lstInventory.Selected(i) is always false ... variable output - comp.soft-sys.matlabNicholas, since 'x' is a vector, 'if x' doesn't return a boolean value (true or false). x=0:0.1:10; IDX = x >= 5; y = NaN(size(x)); y(IDX) = 2*x(IDX); y(~IDX)= 3 ... write read string data - comp.lang.java.helpThe value of the comparison (true or false) is ignored and you happily continue with checking if your string is not null. Perhaps you wanted something like this ... Setting field values and locking fields in iText - comp.text.pdf ...Establish When Multiple Fields Are True/False ... I have a table which has multiple flags set for various eventand can be true or false. ... Assign value based on value ... Boolean data type - Wikipedia, the free encyclopediaIn computer science, the Boolean or logical data type is a data type, having two values (usually denoted true and false), intended to represent the truth values of ... PHP: Booleans - ManualPHP does not break any rules with the values of true and false. The value false is not a constant for the number 0, it is a boolean value that indicates false. 7/3/2012 8:00:57 AM
|