-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Feature request - There should be a "sign" option in the (math operator of value) block. This would return 1, 0, or -1 depending on whether the given value is positive, zero, or negative. There is a fairly straightforward workaround - "(value) / (abs of (value))" (*) - but it is rather verbose, requiring that the block representing the value be used twice, which can cause relatively large blocks:
(Now imagine if the variable were a reporter containing blocks itself, e.g. a list item getter!)
The only confusion I can see arising would be in vocal discussion - the phrase "the sign of block" sounds no different from "the sine of block" - but since these blocks would usually be discussed within context where which choice is meant is obvious, I don't think this is a significant blocker.
(* PS! This workaround actually doesn't work for zero - 0 / abs of 0 is just 0/0, which reports as NaN. Accounting for zero requires many more blocks and likely stack/non-reporter blocks as well.)
