Hi,
It's like multiplying by 1/256 units. In other words the result = x */ 640 is the same as saying result = x * 640 / 256.
What happens internally is a 16*16bit multiplication which results in a 32bit result but the the middle 16bits are returned as the result and the 8 lowest significant bits are discarded.
Let's try this:
result = 100 */ 640
Internally this results in a value of 64000, which, when looked at as 32bits, are 00000000 00000000 11111010 00000000
Then the middle 16bits are returned and assigned to the variable result, ie 00000000 11111010 which in decimal is 250.
100*640/256=250
Put yet another way, let's say you need to multiply a value by 3.64 (100*3.64=364). The value to use with the */ operator is first calculated as 3.64*256=932 (rounded).
result = 100*/932
Internally you'll get 100*932=93200 which is then "divided" by 256 (simply by returning the middle 16 bits of the 32bit intermediate result) before it's returned to you. 93200/256=364 which is what we'd expect.
/Henrik.




Bookmarks