why -1 evaluates true
Posted on August 1st, 2008 by Yousef Ourabi
Languages that do not have native boolean data-types that let you branch on non-boolean data types evaluate all non zero values as “truthy”, (-1) evaluates to true. You might be wondering, as I did, why that is? After poking around and looking at some x86 assembly instructions, I suspect it is a compiler optimization.
At [...]
Filed under: Programming | View Comments