Show pagesourceOld revisionsBacklinksBack to top Share via Share via... Twitter LinkedIn Facebook Pinterest Telegram WhatsApp Yammer RedditSend via e-MailPermalink × Table of Contents Math Number Operation Random integer Random fraction Increase variable Constrain value Map value Mathematical functions Trigonometric functions Mathematical constants Number checks Rounding a number Remainder Math Number This block allows you to define a positive or negative number and use it as part of another block. This number can either be an integer, e.g. -58, or a float, e.g., 1.58. Operation With this block you can make basic mathematical operations on two numbers. Options: +: addition -: substraction x: multiplication %: division ^: exponentiation Random integer This block returns an integer between or equal to the two specified numbers, which is generated randomly at each call. Random fraction This block returns a random floating point number larger or equal to 0.0 and strictly smaller than 1.0. Increase variable This block, adds a number to a selected variable. When choosing a negative number, the number is substracted. Constrain value This block restricts a value to a specified range. The result will be identical if the value is between the two limits. In case the value is smaller than the minimum (resp larger then the maximum), the result will be set to the minimum (resp maximum). Map value Mathematical functions This block allows you to apply classical mathematical functions to numbers. Options: square root absolute: a number's numerical value without regard to its sign -: opposite number (sign reversed) ln: logarithm with base e log10: logarithm to base 10 e^: exponentiation with base e 10^: exponentiation with base 10 Trigonometric functions This block allows you to apply classical trigonometric functions to numbers. Options: sin: calculates the sine of an angle (in radians), result is between -1 and 1 cos: calculates the cosine of an angle (in radians), result is between -1 and 1 tan: calculates the tangent of an angle (in radians), result is between negative infinity and infinity asin: calculates the arc sine of a given number in radians acos: calculates the arc cosine of a given number in radians atan: calculates the arc tangent of a given number in radians Mathematical constants This block provides you with mathematical constants. Options: π: Archimedes' constant, equals approximately to 3.1415926535 e: Euler's number, equals approximately to 2.7182818284 φ: Golden ratio, equals approximately to 1.61803398874 sqrt(2): Pythagoras' constant, square root of 2, equals approximately to 1.4142135623 sqrt(1/2): square root of 1/2 ∞: infinity Number checks With this block you can do typical number checks. The result will be true or false. Options: even: checks if an integer is even (divisible by 2) odd: checks if an integer is odd (not even) prime: checks if an integer is a prime number whole: checks if a number is an integer positive: checks if a number is > or = to 0 negative: checks if a number is < than 0 divisible by: checks if a number is divisible by a given number Rounding a number This block allows you to round a floating point number to an integer. Options: round: rounds the number to the nearest integer, e.g. round(5.6) = 6 round up: rounds the number to the nearest integer larger than the number, e.g. round(5.2) = 6 round down: rounds the number to the nearest integer smaller than the number, e.g. round(5.6) = 5 Remainder This block returns the remainder after division of one number by another. E.g. remainder of 11 % 2 will return 1, or remainder of 19 % 10 will return 9 en/programmingblocks/math.txt Last modified: 2018/07/18 08:36by kniwwelino Log In