Advertisement
pintcat

8 bit ring rotation

Jun 27th, 2025 (edited)
500
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.30 KB | Science | 0 0
  1. #!/bin/sh
  2. # 8-Bit ring rotation to the left
  3.  
  4. VAL=$(($1&0xFF))                       # limit mask to 8 bit
  5. while [ $((LOOP=$LOOP+1)) -le $2 ]; do
  6.     HBIT=$((($VAL&0x80)>>7))           # extract highest bit (bit 7)
  7.     VAL=$(((($VAL<<1)|HBIT)&0xFF))     # rotate left, mask to 8 bit
  8. done
  9. exec numeric.sh $VAL
  10.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement