Mega Code Archive

 
Categories / Delphi / Algorithm Math
 

How to fastly retrieve the high order word from 32bit var

Title: How to fastly retrieve the high-order word from 32bit var The HiWord function retrieves the high-order word from the given 32-bit value. Instead of using HiWord(var32) use: Word(var32 shr 16) this is over 60% faster then calling HiWord() function. Don't make procedure or function out of it (you'll kill the speed). You could use Word(var32) over LoWord(var32) but it's less then 1% faster.