Amazon Interview Question

Write a code to reverse binary bit pattern for an integer without using any string or utility methods?

Interview Answers

Anonymous

Apr 5, 2010

there is rol and ror operations which can be useful to shift places and also the left most digit can move to the end during the operation.

Anonymous

Apr 5, 2010

http://www.intel.com/software/products/documentation/vlin/mergedprojects/analyzer_ec/mergedprojects/reference_olh/mergedProjects/instructions/instruct32_hh/vc270.htm this might be helpful

Anonymous

Jun 9, 2011

unsigned int a=123; // Given number unsigned int b=0; /// temp variable int i; for(i=0; i>1; }

Anonymous

Jun 9, 2011

unsigned int a=123; // Given number unsigned int b=0; /// temp variable int i; for(i=0; i> 1; }

Anonymous

Jun 9, 2011

pls ignore my first ans.

Anonymous

Feb 12, 2010

hit use bitwise operations like bitwose OR, shift left, and shift right.