Mod mathematical function

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.
Post Reply
Aeros
Journeyman Poster
Posts: 69
Joined: Mon Apr 24, 2006 10:56 am

Mod mathematical function

Post by Aeros »

Quick question - is there an equivalent of the mathematical function "mod" in POL atm?

I can't find it anywhere in the script refs, but cant imagine it not being in pol at all either. Alternatively, is there any way to determine the remainder of a divided number?
User avatar
CWO
POL Expert
Posts: 1160
Joined: Sat Feb 04, 2006 5:49 pm

Post by CWO »

dont know how well this will work but it should for remainders to division...

remainder := numerator - ( CInt(numerator / denominator) * denominator);

I also looked for something before to find remainders. Something like the % operator in many languages.
Lagoon
Grandmaster Poster
Posts: 118
Joined: Sun Mar 05, 2006 7:25 am

Post by Lagoon »

escript has the mod operator %
Aeros
Journeyman Poster
Posts: 69
Joined: Mon Apr 24, 2006 10:56 am

Post by Aeros »

Yeah, I also did it like this, wrote my own mod function to handle these things, basically containing:

Code: Select all

	var f := Cint(e / 7);
	var g := Cint(e - (7 * f));
Where the formula was basically "e mod 7", g being the answer to this.
User avatar
Austin
Former Developer
Posts: 621
Joined: Wed Jan 25, 2006 2:30 am

Post by Austin »

Try Print ( 9 % 2 )

% is the mod. operator.
Danielle
Grandmaster Poster
Posts: 104
Joined: Tue Feb 07, 2006 3:32 pm

Post by Danielle »

Aeros
Journeyman Poster
Posts: 69
Joined: Mon Apr 24, 2006 10:56 am

Post by Aeros »

I did - just the wrong manual in this case. Was looking for it in math.em.
User avatar
CWO
POL Expert
Posts: 1160
Joined: Sat Feb 04, 2006 5:49 pm

Post by CWO »

Well actually Danielle I learned POL through Raclac's EScript Guide which is somewhat of a manual til this day and I never knew it existed because there isnt 1 % char in that entire thing.
User avatar
tekproxy
Forum Regular
Posts: 352
Joined: Thu Apr 06, 2006 5:11 pm

Post by tekproxy »

You can usually count on these guys: + - * / ^ %
Danielle
Grandmaster Poster
Posts: 104
Joined: Tue Feb 07, 2006 3:32 pm

Post by Danielle »

CWO wrote:Well actually Danielle I learned POL through Raclac's EScript Guide which is somewhat of a manual til this day and I never knew it existed because there isnt 1 % char in that entire thing.
I know, which is why I'm trying to write a new one; the wiki.
Lagoon
Grandmaster Poster
Posts: 118
Joined: Sun Mar 05, 2006 7:25 am

Post by Lagoon »

Danielle wrote: I know, which is why I'm trying to write a new one; the wiki.
Which is a great project, I hope many guys here will contribute to it, it's coming along very nicely.. personally I'd like to contribute... I'm sure I will, I only need to find the force to fill my wiki-editing-ignorance gap :P
MuadDib
Former Developer
Posts: 1091
Joined: Sun Feb 12, 2006 9:50 pm

Post by MuadDib »

I asked you in irc later, if you meant modulos, cuz that is what I called the %, which I knew existed already, hehe

I see how it is, just ignore the lonely guy who never talks :)
Aeros
Journeyman Poster
Posts: 69
Joined: Mon Apr 24, 2006 10:56 am

Post by Aeros »

Lol, ohhh, i saw that later yeah :P
Post Reply