Explicit conversion to boolean: Boolean, CBool

The required type conversion can be carried out as follows:

explicit conversion to boolean

Description

( type ) expression

Input


Output

Note: In C like languages the data type size may be different depending on compiler and architecture, we show only one standard look.
Compatible programing languages:
C++ | Visual C++ .NET | C# | Java | PHP

Examples

Example

Explicit conversion to boolean the possible of use:
x= true; y= false;
bool b = x;          // b = true
bool b2 = x && y;    // b2 = false
bool b3 = (bool) 0;  // b3 = false

Boolean

Description

 Boolean (expr)
Used keywords: boolean

Input


Output

Compatible programing languages:
JavaScript | Object Pascal | Free Pascal | Pascal

Examples

Object Pascal

Explicit conversion to boolean the possible of use:
x:= true; y:= false;
b:= x;          // b = true
b2:= x and y;    // b2 = false
b3:= Boolean( 0);  // b3 = false

CBool

Description

 CBool (expr)
Used keywords: cbool

Input


Output

Compatible programing languages:
Visual Basic .NET | FreeBASIC

Examples

Visual Basic .NET

Explicit conversion to boolean the possible of use:
x= true
 y= false
Dim b As boolean= x          ' b = true
Dim b2 As boolean= x and y    ' b2 = false
Dim b3 As boolean= CBool( 0)  ' b3 = false

You can find it in the following collections: explicit type conversions
Explicit conversion to boolean in another programming language:
Languages: en hu cz sk