PDA

View Full Version : Math Operations on pbp



Jannia04
- 24th May 2007, 06:38
Hi!
i'm new here!
i've been around looking for answers that may help me. I need some math operations but they have to be "kind of" signed.
Let me see if I understood: If i use "+" or "-" actually i won´t have a signed result 'cause i´m not using "signed math".... BUT if i make something like 8-10 .... so.... i´ll have my answer in complement to two??

What i need is a calculation like:
m(k) = 100 e(k) - 81e(k-1) + 100 m(k-1)

(yes... it's part of an iterative algorithm)
I don't need to know if m(k) is positive or negative (in good theory it will be positive each time!) just need every operation goes correct w/its respective sign.... so can I JUST use add and subtract commands of PBP??

mackrackit
- 24th May 2007, 12:44
http://www.picbasic.co.uk/forum/showthread.php?t=6252&highlight=negative+numbers

Jannia04
- 24th May 2007, 15:05
I already have read that....
just wanna be sure if I understood as I said
I´m not sure if in that case i need or not, use the "S"
Thats what i need to know

tnx again

mackrackit
- 24th May 2007, 15:33
I think you are looking for the Absolute Value of a number.

8-12=(-4)
The absolute value is |4|

PBP has an ABS function.

Example:
NUM = 8-12
NUM2 = ABS NUM

NUM2 will now be |4|