Author Topic: Arithmetics in IRD  (Read 2204 times)

Offline water235

  • Newbie
  • *
  • Posts: 47
  • Karma: 0
Arithmetics in IRD
« on: September 29, 2014, 07:01:16 PM »
Just that I m curious, is there anyway I could perform a modulo operation in IRD,
like
1. get a count
2. if count >12, perform count%12, and set it to be the value of count, and perform further routing >

Thanks for any pointers/help

Offline terry

  • Sr. Member
  • ****
  • Posts: 328
  • Karma: 35
Re: Arithmetics in IRD
« Reply #1 on: September 29, 2014, 09:53:33 PM »
IRD "by default" uses language where there is no built in modulo operation.

Instead when working with integer types (variables of type INTEGER) it generates "integer ariphmetic" "machine instructions", so X mod Y is the same as X - (X/Y)*Y or something like count= count - (count/12)*12



 

Offline water235

  • Newbie
  • *
  • Posts: 47
  • Karma: 0
Re: Arithmetics in IRD
« Reply #2 on: September 30, 2014, 02:50:29 PM »
Thanks, this is much easier.

I did it by another way -
i did a sequencial subtraction(dividend = divend - divisor) until divisor is less or lesser than equal to dividend, increasing the quotient count by 1!
in the end reminder = dividend, there by obtaining the quotient and reminder!