PDA

View Full Version : Help : Byte calculation question



luminas
- 7th April 2012, 19:54
how to get result C ?
C shall be byte size integer

input :
A : byte , function as a ratio to B
B : byte

output:
C : byte

for example :
if A = 100
if B = 200
result shall be 78 :

Formula : C= (A /255 * B)



To get result, I tried :
C = A / 255 * B

and

C= A */ B


but I cannot get C = 78, am I missing something ?

Thank you

aratti
- 7th April 2012, 22:04
Since the operand */ takes the middle 16 bits risult C must be a word variable

Cheers


Al.

luminas
- 9th April 2012, 09:10
Ok, it works now . Thank you Aratti