HP Forums

Full Version: Integer Division
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is there an operator for integer division? (I know about IP(value), but was looking for something like '\').

Thanks,

-Dale-
(03-05-2014 09:29 PM)DrD Wrote: [ -> ]Is there an operator for integer division? (I know about IP(value), but was looking for something like '\').

You have the Integer Quotient CAS command "iquo()".

In algebraic mode: iquo(122,3) returns 40.

In RPN mode: 122 Enter, 3 Enter iquo(2) returns 40.

Mark Hardman
(03-05-2014 09:29 PM)DrD Wrote: [ -> ]Is there an operator for integer division? (I know about IP(value), but was looking for something like '\').

Thanks,

-Dale-

Are you looking for iquo(a,b) or if you want the remainder as well iquorem(a,b) in the CAS?

Cheers, Terje
I was hoping to find a SINGLE character that would implement integer division. I was working with a compound expression requiring multiple integer divides, and that expression gets very l-o-o-o-n-g, with the varieties of ixxx(blah,blah) discovered so far.

Some languages use the backslash character, providing a very short solution to integer division.

Example: 5\2=2, integer version.
5/2=2.5 exact version.

(I did try to DEFINE the backslash character for this use, but \ is an invalid name input.)

-Dale-
(03-06-2014 10:31 AM)DrD Wrote: [ -> ]I was hoping to find a SINGLE character that would implement integer division.

I miss the "\" operator for integer division too. I'm used to it from UBASIC, which also uses "@" for mod (integer remainder).

There is no single-character integer division operator in PPL. iquo(a,b) is your shortest option, unless you make a user-defined function with an even shorter name. UDF's cannot be infix operators, however, so you're stuck with prefix notation.
Reference URL's