sign() : Sign of Number
On this page
Summary
Get the sign of a number (-1, 0, or 1).
Signature
sign(value)
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
value |
Number | Yes | The number to check |
Returns
Type: Integer
-1if value is negative0if value is zero1if value is positive
Examples
Check Sign
Data:
doc.Params["model"] = new {
balance = -150.00m
};
Output:
<p class="negative">Debit: $150</p>
Profit/Loss Indicator
Data:
doc.Params["model"] = new {
accounts = new[] {
new { name = "Account A", change = 5.2 },
new { name = "Account B", change = -3.1 }
}
};
Output:
<tr>
<td>Account A</td>
<td>▲ 5.2%</td>
</tr>
<tr>
<td>Account B</td>
<td>▼ 3.1%</td>
</tr>
Direction Indicator
Notes
- Returns integer: -1, 0, or 1
- Useful for determining direction
- Often used with
abs()for magnitude - Common in financial and trend displays