c++ - Conditioning for the four cases of the signs of two numbers -
i have 2 numbers , b. condition 4 cases of signs of these 2 numbers. do
if ((a >= 0) && (b >= 0)){ // }; if ((a >= 0) && (b < 0)){ // }; if ((a < 0) && (b >= 0)){ // }; if ((a < 0) && (b < 0)){ // };
one produce function outputs different values in each case , use switch{ case:}
statement. functions have thought doesn't improve number of comparisons, there no gain.
which way recommended doing conditioning?
well, guess of if
-s put inside else
-s of others not conditions have evaluated always.
if (a >= 0) { if (b >= 0) { } else // b < 0 { } } else // < 0 { if (b >= 0) { } else // b < 0 { } }
Comments
Post a Comment