Host Engineering Forum
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 21, 2012, 07:14:03 pm


Login with username, password and session length


Pages: [1]
  Print  
Author Topic: IB-521 example for mod results  (Read 858 times)
8bits
Jr. Member
**
Posts: 19


« on: October 17, 2008, 08:18:40 pm »

Hello, can any one give an example on getting the remainder from a IB-521 where it is just simple as:
(V2000/k600). Not sure how to specify to get the remainder and as there is only one destination for the results do I have to
do two separate math operations? Undecided
Logged
Controls Guy
Internal Dev
****
Posts: 1134


Darth Ladder


« Reply #1 on: October 17, 2008, 09:57:59 pm »

The MOD operator is '%', so to get the remainder enter "V2000 % K600" in the expression box.  If you want both the integer quotient and the remainder, yes, you will have to do two operations.
Logged

I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.
franji1
Bit Weenie
Host Moderator
*****
Posts: 1034



WWW
« Reply #2 on: October 18, 2008, 11:26:04 am »

If you need both, and you have both the numerator and denominator in a V memory register, it's best to do it "the old way" because the DIV PLC instruction does both at the same time.  The MATH IBoxes have to do funky math accumulator stack manipulation to work properly to do JUST a divide or JUST a mod.  You actually would end up doing TWO DIV instructions with the two expressions
MATH divresult "Numerator / Denominator"
MATH modresult "Numerator % Denominator "

You would be best off doing in the native math instructions (no IBox)
LD  Numerator
DIV Denominator
OUT divresult
POP
OUT modresult
« Last Edit: October 18, 2008, 11:27:47 am by franji1 » Logged

8bits
Jr. Member
**
Posts: 19


« Reply #3 on: October 18, 2008, 12:51:00 pm »

Thanks for the information, I will do it that way.
 Smiley
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM