_hx_bit_clamp.lua 354 B

12345678910
  1. _hx_bit_clamp = function(v)
  2. if v <= 2147483647 and v >= -2147483648 then
  3. if v > 0 then return _G.math.floor(v)
  4. else return _G.math.ceil(v)
  5. end
  6. end
  7. if v > 2251798999999999 then v = v*2 end;
  8. if (v ~= v or math.abs(v) == _G.math.huge) then return nil end
  9. return _hx_bit.band(v, 2147483647 ) - math.abs(_hx_bit.band(v, 2147483648))
  10. end