$scale (parse-spec, fmultiplier, foffset) function
This function scale the parsed value specified by the first argument by multiplying the value with the fmultiplier floating point number of the second argument and then adding the foffset floating point number of the third argument. All three arguments are required. The result is an integer number rounded down to the nearest integer value.
The following examples show target strings, parse expressions, and return values:
Target string | Parse expression | Return value |
|---|---|---|
N1: 2000 | $scale (n1: *, 0.5, 0) | 1000 Explanation: The parsed value is multiplied by 0.5. |
P1: 20KB | $scale (p1: *, 10, -50) | 150 Explanation: The parse value (not including the KB units) is multiplied by 10 and then 50 is subtracted. |
Q1: 24.999
| $scale (Q1: *, 2, 0) | 49 Explanation: The parse value is parsed as a floating point number, multiplied by two, then rounded down to the nearest integer |
R1: Test | $scale (r1: *, 1, 0) | No match Explanation: The parsed value is not an integer number. |
Related topic