Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // normalized byte multiplication:
- // range [0, 255] maps to [0.0, 1.0]
- // examples:
- // 0xff * 0xff = 0xff (255 * 255 = 255)
- // 0xff * 0x7f = 0x7f (255 * 127 = 127)
- // 0x7f * 0x7f = 0x3f (127 * 127 = 63)
- // 0x01 * 0xff = 0x01 ( 1 * 255 = 1)
- // 0x01 * 0x7f = 0x00 ( 1 * 127 = 0)
- inline byte nmul(byte a, byte b)
- {
- return (((uint16)a + 1) * b) >> 8;
- }
Advertisement
Add Comment
Please, Sign In to add comment