On 12-Sep-08 20:02, Orchid XP v8 wrote:
> Gail wrote:
>
>> How often does a C/C++ programmer really need a function pointer?
>
> Hopefully very rarely...
>
>>> Which one is FALSE? Is that 0 or 1? I know it's one or the other, but
>>> I can never ever remember which - and it's kind of important!
>>
>> 0. Any other value is true.
>
> I remember that 0 is one thing and everything else is the opposite. But
> I can never remember which is which.
It's easy, booleans are a sort of integers following the normal
convention that 0 is false and 1 is true. That any other value also
works comes from the fact that most processors have a zero flag that you
can conditionally jump on. Another example of hardware influencing the
language.
AFAIK the only place where this convention is not used is in shell
scripts in UN*X. Here the reason is that they are originally not
booleans but error codes.
At least that is how I think where the conventions come from. Anyone
more knowledgeable can correct me.
Post a reply to this message
|