Am 08.01.2017 um 18:22 schrieb Sven Barth:

Am 08.01.2017 17:32 schrieb "Bernd Oppolzer" <bernd.oppol...@t-online.de <mailto:bernd.oppol...@t-online.de>>:
>
> Am 08.01.2017 um 11:46 schrieb Sven Barth:
>>
>> On 08.01.2017 10:55, Ryan Joseph wrote:
>>>
>>> I’m going to attempt to translate a perlin noise function (from https://gist.github.com/Flafla2/f0260a861be0ebdeef76) but there are a few things that stopped me from starting.
>>>
>>> 1) What is & doing in this assignment? I see this many places in assignments.
>>>
>>> int h = hash & 15;
>>
>> That's an "and".
>
>
> Please keep in mind that & is a bitwise and in C
> whereas && is a logical and;
> this makes much difference and has to be implemented or converted differently
> with Pascal, IMO.
>
> the closest equivalence to bitwise and in Pascal are set intersections, IMO.

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.

Regards,
Sven



This depends on the Pascal compiler you use;
the old Wirth "Standard" yields syntax errors, if you use and etc. on types
other than boolean:

1 LINE # D/NEST LVL < STANFORD PASCAL, OPPOLZER VERSION OF 01.2017 > 18:32:47 08.01.2017 PAGE 1
   ------  ------ --- ---- ---

        1           ) program TESTAND ( OUTPUT ) ;
        2           )
        3           ) var X , Y : INTEGER ;
        4    360D  1)
        5    360D  1) begin (* HAUPTPROGRAMM *)
        6           )   X := 12 ;
        7      1N  1)   Y := 25 ;
        8      1N  1)   WRITELN ( 'x and y' , X and Y ) ;
     ****                                              E134
        9      1N  1) end (* HAUPTPROGRAMM *) .

     ****       1 SYNTAX ERROR(S) DETECTED.
     ****       9 LINE(S) READ,    0 PROCEDURE(S) COMPILED,
     ****      17 P_INSTRUCTIONS GENERATED,   0.02 SECONDS IN COMPILATION.

     ****  LAST ERROR/WARNING ON LINE -->   8

     ****  ERROR/WARNING CODES FOR THIS PROGRAM :
     ****   134 : ILLEGAL TYPE OF OPERAND(S).

I agree that bitwise and etc. is a useful extension and will
put it on my to-do list.

Have a nice day.

Kind regards

Bernd

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

Reply via email to