Posts: 5,135
Threads: 241
Joined: Nov 2010
Reputation:
100
08-23-2011, 22:04
(This post was last modified: 08-23-2011, 22:06 by Pozzuh.)
Code: setshit()
{
self.derp = [];
self.derp[0] = 1;
self.derp[1] = 2;
self.derp[2] = 3;
self.derp[3] = 4;
self.derp[4] = 5;
self.derp[5] = 6;
self.derp[6] = 7;
}
isintinarray(array,number)
{
for(i=0;i<array.size;i++)
{
if(array[i] == number)
{
return true;
}
}
}
randomfunc()
{
if(isintinarray(self.derp,6))
iprintlnbold("is in ! :D");
}
Something like this? ;o
Now give me +rep for wasting 5 min of my life.
EDIT
apparently this is not what he wanted derp.
Code: numberfunc(num1,num2)
{
if(num1 % num2 == 0)
return true;
else
return false;
}
use it as:
numberfunc(9,3); //will return true
numberfunc(10,3); //will return false
Posts: 1,830
Threads: 104
Joined: Jan 2011
Reputation:
46
Code: isMultiplier( baseNum, number )
{
if( int( number / baseNum ) == ( number / baseNum ) )
return true;
return false;
}
if( isMultiplier( 3, 15 ) )
{
//do shizzle
}
this?
Posts: 5,135
Threads: 241
Joined: Nov 2010
Reputation:
100
(08-23-2011, 22:15)iAegle Wrote: Code: isMultiplier( baseNum, number )
{
if( int( number / baseNum ) == ( number / baseNum ) )
return true;
return false;
}
if( isMultiplier( 3, 15 ) )
{
//do shizzle
}
this?
the part I edited in my post does the same
Posts: 1,830
Threads: 104
Joined: Jan 2011
Reputation:
46
(08-23-2011, 22:16)Pozzuh Wrote: (08-23-2011, 22:15)iAegle Wrote: Code: isMultiplier( baseNum, number )
{
if( int( number / baseNum ) == ( number / baseNum ) )
return true;
return false;
}
if( isMultiplier( 3, 15 ) )
{
//do shizzle
}
this?
the part I edited in my post does the same
k .. what does % do exactly?
Posts: 5,135
Threads: 241
Joined: Nov 2010
Reputation:
100
(08-23-2011, 22:18)iAegle Wrote: (08-23-2011, 22:16)Pozzuh Wrote: (08-23-2011, 22:15)iAegle Wrote: Code: isMultiplier( baseNum, number )
{
if( int( number / baseNum ) == ( number / baseNum ) )
return true;
return false;
}
if( isMultiplier( 3, 15 ) )
{
//do shizzle
}
this?
the part I edited in my post does the same
k .. what does % do exactly?
return the rest value... i've no idea if that's proper english but w/e you're dutch so you'll understand lol.
btw new version of the code (totally made by me )
Code: numberfunc(num1,num2)
{
return(num1 % num2 == 0);
}
Posts: 2,509
Threads: 96
Joined: Nov 2010
Reputation:
38
I think you mean that if you do
21/3 you get 7 and if you do 7/3 your rest value is 7?
Posts: 1,830
Threads: 104
Joined: Jan 2011
Reputation:
46
(08-23-2011, 22:42)surtek Wrote: I think you mean that if you do
21/3 you get 7 and if you do 7/3 your rest value is 7?
nah 21/3 would return 0 because it is an int
22/3 would return 0.333333333333333333333333333
Posts: 18
Threads: 0
Joined: Jul 2011
Reputation:
0
08-24-2011, 04:40
(This post was last modified: 08-24-2011, 04:42 by some_kid.)
% is the modulo operator
it returns the remainder after division
ex.
10 % 3 = 1
3 goes into 10, 3 times (9), then there is 1 left over
9 % 3 = 0
3 goes into 9, 3 times (9), with 0 left over at the end
Code: is_even(num)
{
return (num % 2 == 0);
}
EDIT: for better explanation: http://en.wikipedia.org/wiki/Modulo_operation
Posts: 5,135
Threads: 241
Joined: Nov 2010
Reputation:
100
^that, yes
Posts: 1,185
Threads: 72
Joined: Jan 2011
Reputation:
25
guys. i already know that stuff^^
no need for making a thread xD
|