floating point - Is if(double) valid C++? -


i ran line of code:

if( linedirection.length2() ){...} 

where length2 returns double. kind of puzzles me 0.0 equivalent 0, null, and/or false.

is part of c++ standard or undefined behaviour?

it standard behavior (boolean conversion)

$4.12/1 - "an rvalue of arithmetic, enumeration, pointer, or pointer member type can converted rvalue of type bool. 0 value, null pointer value, or null member pointer value converted false; other value converted true."


Comments

Popular posts from this blog

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

c++ - Convert big endian to little endian when reading from a binary file -