sgn0([lhs], [rhs], [dest], [read_start], [write_start], [group_size], [read_increment], [write_increment], [group_count]): written
Overview
Gets the sign of elements in a userdata, producing -1 for values less than 0, 1 for values greater than 0, and leaving values of 0 untouched.
This function uses the userdata operator signature. Read the bulk operations section of the userdata documentation for a detailed explanation of how the arguments work.
Arguments
[lhs]: userdata|number
The userdata used as the input for the sign operations.
[rhs]: userdata|number
Alternative source userdata. Only used if lhs is not a userdata.
[dest]: userdata|true
The destination userdata to write to. Behavior depends on the type of dest, lhs, and rhs. See the table below.
dest |
lhs |
rhs |
written to |
|---|---|---|---|
| userdata | any | any | dest |
| truthy non-userdata | userdata | any | lhs |
| truthy non-userdata | non-userdata | userdata | rhs |
| falsey | userdata | any | a copy of lhs |
| falsey | non-userdata | userdata | a copy of rhs |
[read_start]: number
The starting index of the inner loop for rhs. Will be floored. Will be clamped to at least 0. Defaults to 0.
[write_start]: number
The starting index of the inner loop for lhs and the destination userdata. Will be floored. Will be clamped to at least 0. Defaults to 0.
[group_size]: number
The number of elements to iterate in the inner loop. Will be floored. A value of 0 or less results in a no-op. Defaults to infinity.
[read_increment]: number
How many elements to move the group starting index for rhs forward by. A value of less than 0 will result in no iteration. Will be floored. Defaults to 1.
[write_increment]: number
How many elements to move the group starting index for lhs and the destination userdata forward by. A value of less than 0 will result in no iteration. Will be floored. Defaults to 1.
[group_count]: number
How many groups will be iterated over.
Returns
written: userdata
The destination userdata, as determined by the [dest] argument.
methods