How to do absolute value in integer math for BS1
tact1cal
Posts: 3
Hi all,
Is there a simple round-about way to subtract (2)· 16-bit numbers and get the absolute value difference? I need this for the·BS1.
Appreciate any simple solutions...
Thanks,
-Guy
Is there a simple round-about way to subtract (2)· 16-bit numbers and get the absolute value difference? I need this for the·BS1.
Appreciate any simple solutions...
Thanks,
-Guy
Comments
Get_Abs:
· IF aVal < bVal THEN B_Bigger
· result = aVal - bVal
· GOTO Abs_Done
B_Bigger:
· result = bVal - aVal
Abs_Done:
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
I had thought about this solution....thanks for simplifying it!
R/
-Guy
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"i want to lead a disipate existence play scratchy records and enjoy my declinw" - iggy pop, i need more
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax