[fpc-devel] Fix for SwapEndian
Jonas Maebe
jonas.maebe at elis.ugent.be
Tue Apr 29 18:26:45 CEST 2008
On 29 Apr 2008, at 17:00, Michael Schnell wrote:
>>> I think shr is supposed to work sign-extending with signed types.
>>
>> The above statement may cause some confusion, so people who think
>> that "shr" means "shift arithmetic right", please read the comment
>> added tohttp://bugs.freepascal.org/view.php?id=10545
> OOPs !?!?!?!
>
> They say: "SHR is /always/ unsigned in TP/FPC/Delphi."
>
> This would mean that the patch the OP mentioned should not be
> necessary
No, it doesn't. The reason is explained in the comment.
> The stuff about first converting and then shifting seems quite queer
> (unless the types left and right are different which imposes queer
> behavior in C, too).
In Pascal, calculations are usually performed using the native integer
type, regardless of the left and right types (there are some
exceptions, but not many). That is not true for C.
Jonas
More information about the fpc-devel
mailing list