David Emerson wrote:
I did cast it to boolean! That's why it smells like a bug
var
b : boolean;
begin
b := boolean (6 and 4);
writeln (t_or_f [b]);
A type cast does not changes the value. A typecast merely allows you to
store a value into a field of a different type
same for enums (boolean is an enum)
type t = (zero, one, two);
var a: t;
a := t(1); // ok
a := t(5); // compiles, gives rangecheck if enabled, otherwise works,
but a is not any of the enum-values
boolvar := boolean(4); // just puts 4 into the variable. doesn't make 4
a valid boolean value
So you need to do
b := (6 and 4) <> 0; // that is a boolean value
writeln (t_or_f [b]);
Martin
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal