On Sun, Jan 8, 2017 at 12:22 PM, Sven Barth <pascaldra...@googlemail.com>
wrote:

> The closest equivalence to bitwise and in Pascal is bitwise and.
>
> The operators "and", "or", "xor" and "not" are logical or bitwise
> depending on their arguments.
>

With that said...



On Sun, Jan 8, 2017 at 11:46 AM, José Mejuto <joshy...@gmail.com> wrote:

>
> Both work the same way but pascal does not have the assignment and testing
> mess that can be written in C like:
>
> C / C++:
>
> a = b && c;
>
> Pascal:
>
> a := (b<>0) and (c<>0);
>

There's another approach to resolved that.

The following code works as expected

{$mode objfpc}

var
  b,c : integer;
  a   : Boolean;
  ai  : integer;
begin
  b:=2;
  c:=3;
  ai:=b and c;
  a:=boolean(b) and boolean(c);
  writeln(a);
  writeln(ai);
  writeln(byte(a));
end.

output:
TRUE
2
1

thanks,
Dmitry
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to