PDA

View Full Version : Dividing numbers > 65***



oslinux
- 24th March 2007, 12:43
Hi all!

I've got this code:



W1 = (W0 * 100) / (I / 1000)


let's suppose that I is 10000 and W0 is 900 we have this:



W1 = (900 * 100) / (10000 / 1000)


now 900 * 100 is executed and return a 32 bit number: 90000
10000/1000 is executed and return an 8 bit number: 10

as you can see, the result 90000/10 is obviously a 16bit number, but PBP will return the right number or i have to use DIV32?

and if i have to use DIV32, it can be done this way?:



W1 = (W0 * 100) DIV32 (I / 1000)


thank you!

Luca

skimask
- 24th March 2007, 17:49
Hi all!

I've got this code:



W1 = (W0 * 100) / (I / 1000)


let's suppose that I is 10000 and W0 is 900 we have this:



W1 = (900 * 100) / (10000 / 1000)


now 900 * 100 is executed and return a 32 bit number: 90000
10000/1000 is executed and return an 8 bit number: 10

as you can see, the result 90000/10 is obviously a 16bit number, but PBP will return the right number or i have to use DIV32?

and if i have to use DIV32, it can be done this way?:



W1 = (W0 * 100) DIV32 (I / 1000)


thank you!

Luca

DIV32 isn't used that way. It's all in the PBP manual, pages 34-36.