![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Note that the value of the Boolean expression, n != 0
, is
0
, meaning false, if and only if the value of n
is
0
. Accordingly, the following while
statements are
equivalent:
while (n != 0) ... while (n) ...
Thus, testing n
to see whether it is not 0
is viewed by some
C++ programmers as a form of lily gilding; such programmers use
n
rather than n != 0
.
Other C++ programmers much prefer n != 0
because they
believe that it is important to maintain a visible distinction
between 0
viewed as a number and 0
viewed as a
truth value.