Jump to content
UBot Underground

odd even numbers


Recommended Posts

Is there any way i can get ubot to distinguish even and odd numbers. and can i get ubot to take the INT part of a number. I have a number 19.5. how can i get it to take only 19, i do not want decimals and floating point numbers

Link to post
Share on other sites

Here's an example on checking if a number is odd using the modulo (%) operator:

post-7-12631606431586_thumb.png

(to check for even, compare it to 0 instead of 1)

 

and here's an example on rounding a number down using Math.Floor:

post-7-12631606640973_thumb.png

 

Let me know if you have any questions. :)

Link to post
Share on other sites

Here's a pretty good list of javascript's math functions:

 

Math.abs(a)     // the absolute value of a
Math.acos(a)    // arc cosine of a
Math.asin(a)    // arc sine of a
Math.atan(a)    // arc tangent of a
Math.atan2(a, // arc tangent of a/b
Math.ceil(a)    // integer closest to a and not less than a
Math.cos(a)     // cosine of a
Math.exp(a)     // exponent of a
Math.floor(a)   // integer closest to and not greater than a
Math.log(a)     // log of a base e
Math.max(a,   // the maximum of a and b
Math.min(a,   // the minimum of a and b
Math.pow(a,   // a to the power b
Math.random()   // pseudorandom number in the range 0 to 1
Math.round(a)   // integer closest to a 
Math.sin(a)     // sine of a
Math.sqrt(a)    // square root of a
Math.tan(a)     // tangent of a

Copy-pasted from here. (gotta give credit haha)

 

All of these can be used inside $eval.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...