Search code examples
maththeory

Split word into two byte - Theory


Just a little question about math..

I have a WORD with that value 25467. I want to get two bytes (lo / hi) from that, that is 123 and 99. There's a way to calculate that two bytes only with a calculator, avoid bitmask (&&) or shifting (<< >>).

Something like (25467 / x) - y = hi word (25467 / x) * z = lo word?


Solution

  • upper = word/(2^8) and lower = word modulo (2^8).