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

unicode - Are email addresses allowed to contain non-alphanumeric characters? -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

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