Page 1 of 1 1
Topic Options
#123087 - 2004-07-15 08:06 PM howto use mod operator
expodium Offline
Fresh Scripter

Registered: 2004-07-14
Posts: 35
hi,

can someone explain me how to use the mod operator?

i cant find any good explanation aboud MOD. And if i search through all forums, i get all issue's where module or moderator in is.

thanks in advance.

Regards,

Expodium

Top
#123088 - 2004-07-15 08:35 PM Re: howto use mod operator
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
MOD is equivalent to the remainder in division. So, for example, 12 mod 5 = 2 and 23 mod 9 = 5.

Does that help?
_________________________
Eric

Top
#123089 - 2004-07-15 08:39 PM Re: howto use mod operator
expodium Offline
Fresh Scripter

Registered: 2004-07-14
Posts: 35
thanks, it is indeed that what im looking for. a easy example.

i need it to create a script to determine the subnetmask (subnetting).

thanks in advance.

regards,

Patrick

Top
#123090 - 2004-07-15 08:41 PM Re: howto use mod operator
MightyR1 Offline
MM club member
*****

Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
Expodium,

this is what I've got from the manual:
mod
Used to divide two numbers and return only the remainder.



so
4 mod 3 returns 1
and
4 mod 2 returns 0


HTH
_________________________
Greetz,
Patrick Rutten

- We'll either find a way or make one...
- Knowledge is power; knowing how to find it is more powerful...
- Problems don't exist; they are challenges...

Top
#123091 - 2004-07-15 08:42 PM Re: howto use mod operator
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11624
Loc: CA
Just as an FYI we have a couple of UDFs that already do just about anything you could want or imagine with subnetting.

Please review the UDF forum or one of the mirror links.

http://www.gwspikval.com/jooel/UDF/

http://www.kixhelp.com/udfs/

Top
#123092 - 2004-07-15 09:10 PM Re: howto use mod operator
expodium Offline
Fresh Scripter

Registered: 2004-07-14
Posts: 35
thanks for the last reply.

But sometime i try some stuff on my one. Like converting a ip number to binary.

Function decToBin($ip1)
For $i = 0 to 7
$ip2 = $ip1/2
$bin = CStr($ip1 mod 2) + $bin
$ip1 = $ip2
Next
EndFunction

and decToBin(192) gives 11000000

but still, thanks for the links

Regards,

Expodium

Top
#123093 - 2004-07-18 05:17 PM Re: howto use mod operator
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Already been done as BinaryIP() - converts an IP# to it's binary value adn posted in the UDF Forum. See also the TCP/IP Primer in the FAQ Forum.
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 303 anonymous users online.
Newest Members
rrosell, PatrickPinto, Raoul, Timothy, Jojo67
17877 Registered Users

Generated in 0.112 seconds in which 0.082 seconds were spent on a total of 14 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org