Handling Arithmetic Right Shifts in ObjectPascal

In translating some DSP C++ code to ObjectPascal, I am seeing a quite a few ">>" operators on signed integers (the right operand always being 1 or 2). I know that on signed integers C++ performs an arithmetic right shift as opposed to a logical right shift in Pascal.

Currently I am substituting a 'div 2' or 'div 4' command for these ASR shifts. Is there a better, or more general, way to handle these?


Yes, assuming that the left operand is a 32-bit variable:



And if you want the general case for x>>N:


Need Your Help

change values in a list without a loop

python algorithm loops

I want to change the values of a list without using a loop or increase the performence

Why exactly is eval evil?

clojure scheme lisp common-lisp eval

I know that Lisp and Scheme programmers usually say that eval should be avoided unless strictly necessary. I’ve seen the same recommendation for several programming languages, but I’ve not yet seen a