# a BOOL veriable 615

Hello freinds,

We say that:

Boolean constants may have the value of true or false, numeric representation of them is 1 or 0, respectively. True or TRUE, False or FALSE can be used, as well.

Examples:

```bool a = true;
bool b = false;
bool c = 1;```

Its internal representation is a long 4-byte integer number. Boolean constants can assume the values of 0 or 1.

I have a problem, and I nnd your help:

The code lines are:

...

bool alfa;

int beta;

int gamma;

...

alfa = 1;

...

beta = alfa * gamma + !alfa * StrToTime("00:00");

My quations are:

Do I right if I say: a bool variable is 0 if it is FALSE, and a bool variable is 1 if it is TRUE?

and:

Why do I get an error massage on the last code line -  "=" - assignment expected ?

Thanks, 126

crossy:

Hello freinds,

We say that:

Boolean constants may have the value of true or false, numeric representation of them is 1 or 0, respectively. True or TRUE, False or FALSE can be used, as well.

Examples:

Its internal representation is a long 4-byte integer number. Boolean constants can assume the values of 0 or 1.

I have a problem, and I nnd your help:

The code lines are:

...

bool alfa;

int beta;

int gamma;

...

alfa = 1;

...

beta = alfa * gamma + !alfa * StrToTime("00:00");

My quations are:

Do I right if I say: a bool variable is 0 if it is FALSE, and a bool variable is 1 if it is TRUE?

and:

Why do I get an error massage on the last code line -  "=" - assignment expected ?

Thanks,

Question 1: right.

What exactly do you try to achieve with that line of code? You mix up different data types. 17411

crossy:

Hello freinds,

We say that:

Boolean constants may have the value of true or false, numeric representation of them is 1 or 0, respectively. True or TRUE, False or FALSE can be used, as well.

I don't say that . . .

Think of a bool as True or False . . .   forget 0 and 1 . . .  where is the logic of trying to do bool * int ?  what goes true * 5 mean ?  very true ? 615

RaptorUK:

I don't say that . . .

Think of a bool as True or False . . .   forget 0 and 1 . . .  where is the logic of trying to do bool * int ?  what goes true * 5 mean ?  very true ?

Thanks Raptor,

Exactly. I agree with you.

My decompiler returned it so. Is there any possibilty to understand it....? I need your help!! 615

crossy:

Thanks Raptor,

Exactly. I agree with you.

My decompiler returned it so. Is there any possibilty to understand it....? I need your help!!

Any one can help? 126

crossy:

Any one can help?

I don't think there is a possibility to understand why different datatypes should be added/multiplicated together. And I am not sure about you should ask questions for decompiled code. However, put !alfa in brackets - (!alfa) - and you have a chance it does compile.
edit: Of course you can e.g. multiplicate a double with an integer and assign it to a double. 17411

crossy:

Thanks Raptor,

Exactly. I agree with you.

My decompiler returned it so. Is there any possibilty to understand it....? I need your help!!

Decompiler ?  please explain  . . . 25838

IMO, there is only one reason to use bool * x and only if you think it simplifies the reading of the code. Variations like:
ExplicitCompact
```if (isSomething) double x = A;
else                    x = B;```
```double x = isSomething * A + !isSomething * B;
```
```double x = A;
if (isSomething) x += B;
```
```double x = A + isSomething * B;
``` 615

kronin:

I don't think there is a possibility to understand why different datatypes should be added/multiplicated together. And I am not sure about you should ask questions for decompiled code. However, put !alfa in brackets - (!alfa) - and you have a chance it does compile.
edit: Of course you can e.g. multiplicate a double with an integer and assign it to a double.

Thanks kronin, It works!!. 615

WHRoeder:
IMO, there is only one reason to use bool * x and only if you think it simplifies the reading of the code. Variations like:
ExplicitCompact

Very intelegent way to solve it.

Thanks WMR