why -1 evaluates true

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 [...]

  • Digg
  • del.icio.us
  • StumbleUpon
  • Technorati
  • Reddit