fork(2) download
  1. using System;
  2.  
  3. public class Test
  4. {
  5. public static void Main()
  6. {
  7.  
  8. uint v = 0x4dead; // 18-th bit is the highest one set
  9. uint r;
  10. uint shift;
  11.  
  12. r = (uint)((v > 0xFFFF) ? 1 : 0) << 4; v >>= (int)r;
  13. shift = (uint)((v > 0xFF ) ? 1 : 0) << 3; v >>= (int)shift; r |= shift;
  14. shift = (uint)((v > 0xF ) ? 1 : 0) << 2; v >>= (int)shift; r |= shift;
  15. shift = (uint)((v > 0x3 ) ? 1 : 0) << 1; v >>= (int)shift; r |= shift;
  16. r |= (v >> 1);
  17.  
  18. Console.WriteLine(r);
  19.  
  20.  
  21. }
  22. }
Success #stdin #stdout 0.03s 33904KB
stdin
Standard input is empty
stdout
18