Carrot reference
Functions
percent()
Given a value, returns that value as a Percent.
percent(value[, places])
- value - the Number, Percent, or String value to be converted to a Percent.
- places - the number of decimal places of the returned Percent value.
percent(50/100) returns 50%.
percent(0.75) returns 75%.
percent(0.5667777, 3) returns 56.678%.
Input type | Return type | Logic |
---|---|---|
Number | Percent | If a Number value is passed, a Percent will be returned only if the Number value is represented using division, ex. 50/100, or if it is a decimal. |
Percent | Percent | If a Percent value is passed, the same Percent value will be returned. |
String | Percent | If a String value is passed a Percent will be returned only if the String value can be converted to a Number value, and that Number value is a decimal. |
Unsupported data types | Null | Unsupported data types return Null. |