Skip to content

Files

Latest commit

 

History

History

Set the kth Bit

A user inputs a number say 32 , and a position say 7.

write a function which takes the number and sets its 7th position counting from least significant digit and then return the resultant number in decimal.

Example-32’s binary representation is 00100000 and after setting its 7th position from least significant position,

the resultant number becomes: 01100000,which is 96.