Re: Help with calculation
Well, probably something like this
Code:
wDummy=wTemp * (wWeight2-wWeight1)
IF wDummy > 65536 THEN
wDummy=wTemp * (wWeight2-wWeight1) 'This line needs to be before DIV32
wTemp= DIV32 100
ENDIF
Re: Help with calculation
@ first ...
could you explain how DIV32 results can be > 16 bits ...
Never seen that for 14 Years I use PBP !
Ok, ...
1) The "Dummy" variable must be < 32768 ... see Manual !
2) IF you use DIV32 ... your program variables only can be < 16 Bits ( 65535 ), obvious, eh ! ( DIV32 doesn't work when LONGS used !!! :rolleyes: )
=> soooo, how are you dealing with your supposed 16 -> 32 bits intermediate "results" ???
BTW :
Code:
IF wDummy > 65536 THEN
" another " compiler would have sent you the message
Quote:
Condition always TRUE
Alain
Re: Help with calculation
Quote:
Originally Posted by
Acetronics
@ first ...
could you explain how DIV32
results can be > 16 bits ...
Never seen that for 14 Years I use PBP !
Ok, ...
1) The "Dummy" variable must be < 32768 ... see Manual !
2) IF you use DIV32 ... your program variables only can be < 16 Bits ( 65535 ), obvious, eh ! ( DIV32 doesn't work when LONGS used !!! :rolleyes: )
=> soooo, how are you dealing with your supposed 16 -> 32 bits intermediate "results" ???
BTW :
Code:
IF wDummy > 65536 THEN
" another " compiler would have sent you the message
DIV32 results are never over 16bits. What I meant is that my calculation in the following sentence
wDummy=wTemp * (wWeight2-wWeight1)
Can result in result of upto 16 bits, which is fine as wDummy can handle it. But in cases when it gets over 16bits for example if wTemp is 100 and result of the subtraction is 100 as well, DIV32 gets me what I want. i.e. 10,000 in this example.
BUT the problem is that I am not sure if DIV32 is still doing something to my answer when the result is up to 16 bits as I would not like DIV32 to execute in this case. Hope I made myself more clear this time.