AllAlgorithms / c

Implementation of All ▲lgorithms in C Programming Language
https://github.com/AllAlgorithms/c
MIT License
1.44k stars 520 forks source link

Added file for left and right shift rotation #427

Open AnshumanAryan24 opened 8 months ago

AnshumanAryan24 commented 8 months ago

Added the following: Bit-Manipulation: Rotate right and rotate left. Note: Only applicable for positive integers

  1. rotate_right(num, times): rotate num(passed as decimal) "times" times towards right and return eg.: rotate_right(12, 1) --> 6
  2. rotate_left(num, times): rotate num(passed as decimal) "times" times towards left and return eg.: rotate_left(12, 2) --> 3 Additional functions:
  3. unsigned dec_to_bin(num): return decimal form of binary format number eg.: dec_to_bin(12) --> 1100
  4. unsigned bin_to_dec(bin): return binary form of decimal format number eg.: bin_to_dec(1100) --> 12