Example:
rol() { num="$@" ; pre=$((num<<13)) ; suf=$((num>>19)) ;
num=$((pre^suf)) ; num=$((num&0xffffffff)) ; echo "$num" ; }
What tricks will make this more efficient in Bash?
SugarBug <3883@sugar.bug> writes:
Example:
rol() { num="$@" ; pre=$((num<<13)) ; suf=$((num>>19)) ;
num=$((pre^suf)) ; num=$((num&0xffffffff)) ; echo "$num" ; }
What tricks will make this more efficient in Bash?
If you can be sure the input will never be 0xffffffff, then this should
work:
rol () { echo "$(($1*8192%0xffffffff))" ; }
Phil
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 489 |
Nodes: | 16 (2 / 14) |
Uptime: | 54:02:12 |
Calls: | 9,673 |
Calls today: | 4 |
Files: | 13,719 |
Messages: | 6,170,784 |