ugakebet 4 Posted January 10, 2010 Report Share Posted January 10, 2010 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 Quote Link to post Share on other sites
alcr 135 Posted January 10, 2010 Report Share Posted January 10, 2010 I think javascripts is your solution. Just wait for the JS guys to step in and see what they say about it. Quote Link to post Share on other sites
Guest Jim Posted January 10, 2010 Report Share Posted January 10, 2010 Here's an example on checking if a number is odd using the modulo (%) operator:(to check for even, compare it to 0 instead of 1) and here's an example on rounding a number down using Math.Floor: Let me know if you have any questions. Quote Link to post Share on other sites
Aaron Nimocks 19 Posted January 10, 2010 Report Share Posted January 10, 2010 Math.Floor? Wheres the list of all these Jim? Quote Link to post Share on other sites
Guest Jim Posted January 10, 2010 Report Share Posted January 10, 2010 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. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.