function luaY.int2fb(x,Q)local n=0 while Q>=16 do Q=math.floor((Q+1)/2)n=n+1 end if Q<8 then return Q else return(n+1)*8+(Q-8)end end

function luaY:int2fb(x)
  local e = 0  -- exponent
  while x >= 16 do
    x = math.floor((x + 1) / 2)
    e = e + 1
  end
  if x < 8 then
    return x
  else
    return ((e + 1) * 8) + (x - 8)
  end
end
