What the value return from this condition?

Viewed 21
  1. !10 < 11; // Evaluates to: TRUE
  2. !(10 < 11); // Evaluates to: FALSE

the first option I am confused about is return values. but the second value return is ok.

2 Answers

If this is a C-like language, !10 means “negate logical expression’10’”.

An integer will be considered false only if it’s 0. So 10 is true and !10 evaluates to false.

In a numeric context false is 0, which is less than 11.

!(10 < 11) first the parantheses or bracket value will execute 10<11 which is true then ! exclamatory marks which means not true it will change true into false so the answer is false. !10 < 11 here first !10 means it's false or 0 when 0 < 11 execute it will return true.

Related