What does “!” operator mean in javascript when it is used with a non-boolean variable?

Any falsy value will satisfy the if(!insert_variable_here) condition, including: false null undefined The empty string ” The number 0 NaN If callback return evaluates any of those values, the condition will be satisfied. Even though null != false, the following will give you an alert: x = null; if(!x) { alert(‘”!null” does evaluate to true’); … Read more

Under what circumstances are __rmul__ called?

When Python attempts to multiply two objects, it first tries to call the left object’s __mul__() method. If the left object doesn’t have a __mul__() method (or the method returns NotImplemented, indicating it doesn’t work with the right operand in question), then Python wants to know if the right object can do the multiplication. If … Read more

Comparing float and double primitives in Java

Take a look at What every computer scientist should know about floating point numbers. Squeezing infinitely many real numbers into a finite number of bits requires an approximate representation…. — Edit to show what the above quote means — You shouldn’t ever compare floats or doubles for equality; because, you can’t really guarantee that the … Read more

What is ‘:-!!’ in C?

This is, in effect, a way to check whether the expression e can be evaluated to be 0, and if not, to fail the build. The macro is somewhat misnamed; it should be something more like BUILD_BUG_OR_ZERO, rather than …ON_ZERO. (There have been occasional discussions about whether this is a confusing name.) You should read … Read more