May 29, 2015 at 5:18pm UTC
A common mistake, each comparison needs be be written out.
if (( MIN_HOURS <= hoursTaken <= MAX_HOURS1)
Needs to be:
if (( MIN_HOURS <= hoursTaken && hoursTaken <= MAX_HOURS1)
May 29, 2015 at 6:10pm UTC
Ah ok, thank you! I wonder why they don't allow it the way I originally had it.
May 29, 2015 at 7:00pm UTC
well, it works, but not the way you want it...
because of the operator priority and left-to-right opartors for same-level operators:
if ((MIN_HOURS <= hoursTaken) <= MAX_HOURS1)
its the same as:
a + b + c
which is equivalent to
((a + b) + c)
the only difference is the operator
Last edited on May 29, 2015 at 7:02pm UTC
May 29, 2015 at 7:16pm UTC
Yes..
(MIN_HOURS <= hoursTaken)
return bool (0 or 1)
which it always less than MAX_HOURS1
May 29, 2015 at 7:40pm UTC
Gamer2015 that makes a lot of sense, and thank you for breaking it down obscure.