mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-21 20:09:25 +02:00
* fixed swap(integer) due to counter-intuitive TP/Delphi compatible
shr-behaviour git-svn-id: trunk@6752 -
This commit is contained in:
parent
f1e218ffe0
commit
c630797934
@ -190,7 +190,11 @@ End;
|
||||
|
||||
Function Swap (X : Integer) : Integer;{$ifdef SYSTEMINLINE}inline;{$endif}
|
||||
Begin
|
||||
swap:=(X and $ff) shl 8 + (X shr 8)
|
||||
{ the extra 'and $ff' in the right term is necessary because the }
|
||||
{ 'X shr 8' is turned into "longint(X) shr 8", so if x < 0 then }
|
||||
{ the sign bits from the upper 16 bits are shifted in rather than }
|
||||
{ zeroes. Another bug for TP/Delphi compatibility... }
|
||||
swap:=(X and $ff) shl 8 + ((X shr 8) and $ff)
|
||||
End;
|
||||
|
||||
Function swap (X : Longint) : Longint;{$ifdef SYSTEMINLINE}inline;{$endif}
|
||||
|
Loading…
Reference in New Issue
Block a user