Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 12th, 2012  |  syntax: None  |  size: 0.19 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. def split(x)
  2.   hx = (x & (~((1<<31)-1))) >> 31
  3.   lx = x & ((1<<31)-1)
  4.   [lx, hx]
  5. end
  6.  
  7. def merge(lx, hx)
  8.   (hx << 31) + lx
  9. end
  10.  
  11. def foo(x)
  12.   lx, hx = split(x)
  13.   merge(-hx, lx)
  14. end