() of ()

From PenguinMod Wiki
Revision as of 22:23, 8 July 2024 by MediansSC (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

() of () (Operators)
Jump to navigation Jump to search
() of ()
...
[[File:|200px]]
Caption
Block Type Reporter Block
Category / Extension Operators
Status Who tf uses status

The () of () block is a reporter block in the Operators category that allows for various functions to be used on a specific number. It originates from Scratch. All of the trigonometric functions are calculated in degrees.

Operator Description Example Default
abs Absolute value (distance of the number from 0) The distance of 3 and -3 from 0 would both be 3, and the distance of 0 from 0 would just be 0 Yes
floor Floor function (always rounds a decimal down) 4.5 becomes 4, 10.1 becomes 10, 13.9 becomes 13, and 9 stays as 9 No
ceiling Ceiling function (always rounds a decimal up) 4.5 becomes 5, 10.1 becomes 11, 13.9 becomes 14, and 9 stays as 9
sqrt Square root Entering 4 would return 2, and 16 would return 4.
sin Sine Entering 30 would result in 0.5, and 180 would result in 0
cos Cosine Entering 30 would result in around 0.866, and 180 would result in -1.
tan Tangent Entering 45 would result in 1, and entering 180 would result in 0.
asin Arcsine (inverse sine) Entering 0.5 would result in 30, and entering 0 would result in 0.
acos Arccosine (inverse cosine) Entering 0.5 would result in 60, and entering 0 would result in 90.
atan Arctangent (inverse tangent) Entering 1 would result in 45, since the tangent of 45 degrees is 1.
ln Natural log (log base e) Entering the e operator would result in 1, and entering 2 would result in a value around 0.693.
log Log base 10 Entering 10 would result in 1, and entering 2 would result in a value that is around 0.301
e ^ Exp function (e^x) Entering 1 would result in e, or Euler's number
10 ^ Raises 10 to a specific power Entering 3 would result in 1000, and entering 6 would result in 1000000.

Workarounds

e ^ and 10 ^ can be replicated by using the () (v) () block, with 10 or the e reporter block as the first input, and "^" selected:

(10) [^ v] (number::grey)::operators reporter

(e::operators) [^ v] (number::grey)::operators reporter

ln and log can work around each other by using the change of base formula for logarithms, and can also be worked around using the () (v) () block with log selected:

//ln workarounds
([log v] of (number::grey)) / ([log v] of (e::operators))
(e::operators) [log v] (number::grey)::operators reporter
//log workarounds
([ln v] of (number::grey)) / ([ln v] of (10))
(10) [log v] (number::grey)::operators reporter

abs can be worked around using the sqrt option on the square of the number, or by multiplying the number by the sign of the number using the sign of () reporter block:

[sqrt v] of ((number::grey) [^ v] (2)::operators)
[sqrt v] of ((number::grey) * (number::grey))

(number::grey) * (sign of (number::grey))

sin(90 - x) = cos(x) and cos(90 - x) = sin(x). tan(x) = sin(x)/cos(x), so that option can be worked around by using the sin and cos options.