#How does C treat numeric values as bool?

18 messages · Page 1 of 1 (latest)

earnest dirge
#

I know that 0 is false, so any !0, therefore !false, is true?

hollow sandBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For more information use !howto ask.

swift kelp
#

only in a logical sense

#

you can put it in a if statement

#

but !0 is not 1 in the sense that you can do arithmetic with it

#

unless C standard says something specifically about this cas

#

crap I completely misunderstood your question

#

but yeah your thought is correct

earnest dirge
#

awesome, thanks !

#

Thanks @swift kelp

#

ok bot not working

#

Thanks

#

ok

hollow sandBOT
#

@earnest dirge Has your question been resolved? If so, run !solved :)

loud cargo
#

In C all conditions as you said true if non zero

#

So in a true false(execute or skip) context ~0 = 1 = 2

#

Please remember to use !solved if you have your answer

earnest dirge
#

!solved