Re: Need a hand with a small C conversion

new topic     » goto parent     » topic index » view thread      » older message » newer message

sorry, forgot to format.

-- positive shift left  
-- negative shift right 
global function bitshift(atom x, atom shift) 
  return floor(x * power(2,shift) 
end function  
 
global function lshift(atom x, atom shift) 
  return bitshift(x,shift) 
end function  
 
global function rshift(atom x, atom shift) 
  return bitshift(x,-shift) 
end function  
 
------------------------------------------------ 
global function lo_word( atom a ) 
------------------------------------------------ 
-- syntax: i = lo_word( a ) 
-- description: 
--    returns the low word(2 bytes) i, from the long(4 bytes) a 
 
    -- return low word 
    return and_bits( a, #FFFF ) 
end function 
 
------------------------------------------------ 
global function hi_word( atom a ) 
------------------------------------------------ 
-- syntax: i =  hi_word( a ) 
-- description: 
--    returns the high word(2 bytes) i, from the long(4 bytes) a 
 
    -- return high word 
    return and_bits(floor( a / #10000 ), #FFFF) 
end function 
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu