Re: [fpc-pascal] Conversion from C to Pascal - Left bit shift

2021-09-04 Thread Jonas Maebe via fpc-pascal
On 03/09/2021 08:02, LacaK via fpc-pascal wrote: >> I have code in C like this: >>   E1 << E2 >> If E1 is of unsigned type then "The value of E1 << E2 is E1 >> left-shifted E2 bit positions; vacated bits are zero-filled. If E1 has >> an unsigned type, the value of the result is E1 × 2^E2, reduced

Re: [fpc-pascal] Conversion from C to Pascal - Left bit shift

2021-09-04 Thread Markus Greim via fpc-pascal
After 35 years of Pascal experience I would urgently recommend NOT to trust any automatic type conversion in the case of shift operators. Alteady Turbo Pascal failed here on x386 architectures. Force input and output variables to a certain data type before you use the shift operator. Just my

Re: [fpc-pascal] Conversion from C to Pascal - Left bit shift

2021-09-03 Thread Jean SUZINEAU via fpc-pascal
I made a few tests on Ubuntu 64 bits (arch x86_64) with variations on a small test program: var    E2: Byte= 3;    E1: LongWord= 1;    E: QWord; begin E:= (1000*E1) shl E2; writeln( 'E2', E2); writeln( 'E1', E1); writeln( 'E', E); end. In the assembly window, shl is computed

Re: [fpc-pascal] Conversion from C to Pascal - Left bit shift

2021-09-03 Thread LacaK via fpc-pascal
Can we say that in Pascal the result of:    E1 shl E2 is of same type as E1 ? (so if E1 is LongWord then result is LongWord also?) What if there is an expression on left side:    (E1*x) shl E2 Will E1*x promote to 64 bits (on 64 bit target)? See documentation on

Re: [fpc-pascal] Conversion from C to Pascal - Left bit shift

2021-09-03 Thread Christo Crause via fpc-pascal
On Fri, Sep 3, 2021 at 8:02 AM LacaK via fpc-pascal < fpc-pascal@lists.freepascal.org> wrote: > Can we say that in Pascal the result of: >E1 shl E2 > is of same type as E1 ? > (so if E1 is LongWord then result is LongWord also?) > > What if there is an expression on left side: >(E1*x) shl

Re: [fpc-pascal] Conversion from C to Pascal - Left bit shift

2021-09-03 Thread LacaK via fpc-pascal
Can we say that in Pascal the result of:   E1 shl E2 is of same type as E1 ? (so if E1 is LongWord then result is LongWord also?) What if there is an expression on left side:   (E1*x) shl E2 Will E1*x promote to 64 bits (on 64 bit target)? -Laco. Hello *, I have code in C like this:   E1 <<

[fpc-pascal] Conversion from C to Pascal - Left bit shift

2021-09-02 Thread LacaK via fpc-pascal
Hello *, I have code in C like this:   E1 << E2 If E1 is of unsigned type then "The value of E1 << E2 is E1 left-shifted E2 bit positions; vacated bits are zero-filled. If E1 has an unsigned type, the value of the result is E1 × 2^E2, reduced modulo one more than the maximum value