On Fri, 7 Dec 2001, Maurice Lombardi wrote:
Gloria, Jing wrote:
Has anybody implemented a function to do Logical Shift Right operations on an integer in GNU PASCAL? SHR operator will do an arithmetic shift right. Or any suggestions on how to do this?
Declare the variable as cardinal (or word) instead of integer.
SHR will then be a logical shift.
Very clever!
I was wondering for a period of time however why no language implemented ROR and ROL operators (rotate right and left) - it may seem unnecessary, but sometimes you have to go to assembler just because C and Pascal miss this operator - it could be very useful, for example in filters, convolutions, CRC checksum calculation and graphics.
Of course, if a range of bytes is rotated, it's very useful to preserve carry flag somewhere - but I guess one has to do asm for that, doesn't he?
Mirsad
-- This message has been made up using recycled ideas and language constructs. No plant or animal has been injured in process of making this message.