Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2009-10

Question about ror / rordword...

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Green

Quick question: Is there any particular reason why the system function ror() (in /fpc/rtl/inc/systemh.inc) has been divided up into rorbyte, rordword and rorqword (and respectively for rol() ) instead of being overloaded?

Reply by email

Florian Klaempfl
to Michael Green
Quick question: Is there any particular reason why the system function ror() (in /fpc/rtl/inc/systemh.inc) has been divided up into rorbyte, rordword and rorqword (and respectively for rol() ) instead of being overloaded?

Ror/rol are very sensitive against data type changes so this ensures you get always the desired result. While x shr 1 has the same result if the value fits in x, ror(x,1) has different results if x is a byte, word or dword even if it's value is e.g. 1.

Reply by email

Michael Green
to Florian Klaempfl

Makes perfect sense, thanks for the quick answer :-)

Florian Klaempfl wrote 5 lines
Ror/rol are very sensitive against data type changes so this ensures you get always the desired result. While x shr 1 has the same result if the value fits in x, ror(x,1) has different results if x is a byte, word or dword even if it's value is e.g. 1.

Reply by email