Perform logical shift using arithmetic shift operator in C [duplicate]
This question already has an answer here: Implementing Logical Right Shift in C 8 answers Right now I am reading the book Computer Systems : Programmer Perspective. One problem in the book says to perform a logical right shift on a signed integer, I can't figure out how to start on this. The following is the actual question from the book: Fill in code for the following C functions. Function srl performs a logical right shift using an arithmetic right shift (given by value xsra ), followed by other operations not including right shifts or division. Function sra performs an arithmetic right