Integer Division
03-05-2014, 09:29 PM
Post: #1
 DrD Senior Member Posts: 1,124 Joined: Feb 2014
Integer Division
Is there an operator for integer division? (I know about IP(value), but was looking for something like '\').

Thanks,

-Dale-
03-05-2014, 10:39 PM (This post was last modified: 03-05-2014 10:39 PM by Mark Hardman.)
Post: #2
 Mark Hardman Senior Member Posts: 506 Joined: Dec 2013
RE: Integer Division
(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

Ceci n'est pas une signature.
03-05-2014, 10:40 PM
Post: #3
 Terje Vallestad Member Posts: 145 Joined: Dec 2013
RE: Integer Division
(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
03-06-2014, 10:31 AM
Post: #4
 DrD Senior Member Posts: 1,124 Joined: Feb 2014
RE: Integer Division
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, 11:44 AM
Post: #5
 Joe Horn Senior Member Posts: 1,612 Joined: Dec 2013
RE: Integer Division
(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.

<0|ΙΈ|0>
-Joe-
 « Next Oldest | Next Newest »

User(s) browsing this thread: 1 Guest(s)