https://people.cs.nctu.edu.tw/~tsaiwn/sisc/runtime_error_200_div_by_0/www.merlyn.demon.co.uk/del-bits.htm
http://www.delphibasics.co.uk/RTL.asp?Name=xor
http://www.delphibasics.co.uk/RTL.asp?Name=shl
https://www.interviewcake.com/concept/java/bit-shift
https://onlinetoolz.net/bitshift
Logical Arithmetic Circular Rotate through carry shift
https://www.geeksforgeeks.org/rotate-bits-of-an-integer/
https://www.freepascal.org/docs-html/rtl/system/roldword.html
https://www.freepascal.org/docs-html/rtl/system/rolbyte.html
https://docwiki.embarcadero.com/RADStudio/Sydney/en/Expressions_(Delphi)
https://docwiki.embarcadero.com/RADStudio/Sydney/en/Bitwise_Operators
https://docwiki.embarcadero.com/Libraries/Sydney/en/System.Classes.TBits.Bits
https://docwiki.embarcadero.com/Libraries/Sydney/en/System.Classes.TBits
https://github.com/StarWong/MyLibary/blob/316624818c46b954206d9cbef4799e6e5250aa60/HashLib4Pascal/HashLib/src/Utils/HlpBits.pas
class function TBits.RotateLeft8(a_value: Byte; a_n: Int32): Byte;
begin
...
a_n := a_n and 7;
Result := (a_value shl a_n) or (a_value shr (8 - a_n));
...
end;
class function TBits.RotateRight8(a_value: Byte; a_n: Int32): Byte;
begin
{$IFDEF DEBUG}
System.Assert(a_n >= 0);
{$ENDIF DEBUG}
{$IFDEF FPC}
Result := RorByte(a_value, a_n);
{$ELSE}
a_n := a_n and 7;
Result := (a_value shr a_n) or (a_value shl (8 - a_n));
{$ENDIF FPC}
end;
class function TBits.RotateRight32(a_value: UInt32; a_n: Int32): UInt32;
begin
{$IFDEF DEBUG}
System.Assert(a_n >= 0);
{$ENDIF DEBUG}
{$IFDEF FPC}
Result := RorDWord(a_value, a_n);
{$ELSE}
{$IFNDEF SHIFT_OVERFLOW_BUG_FIXED}
a_n := a_n and 31;
{$ENDIF SHIFT_OVERFLOW_BUG_FIXED}
Result := (a_value shr a_n) or (a_value shl (32 - a_n));
{$ENDIF FPC}
end;
沒有留言:
張貼留言