From c1be0c51c6187c2ab701c0b7e8789ba87feece23 Mon Sep 17 00:00:00 2001 From: Nicolas Szalay Date: Wed, 26 Oct 2016 14:03:50 +0200 Subject: [PATCH] Add a note about operator precedence. #9169 --- .../source/docs/configuration/interpolation.html.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/website/source/docs/configuration/interpolation.html.md b/website/source/docs/configuration/interpolation.html.md index e000e53ad8..98377c9e5c 100644 --- a/website/source/docs/configuration/interpolation.html.md +++ b/website/source/docs/configuration/interpolation.html.md @@ -344,3 +344,14 @@ it's best to use spaces between math operators to prevent confusion or unexpecte behavior. For example, `${var.instance-count - 1}` will subtract **1** from the `instance-count` variable value, while `${var.instance-count-1}` will interpolate the `instance-count-1` variable value. + + +-> **Note:** Operator precedence is not the usual one where *Multiply* (`*`), +*Divide* (`/`), and *Modulo* (`%`) have precedence over *Add* (`+`) and *Subtract* (`-`). +The operations are made in the order they appear. Parenthesis can be used to force ordering : +``` +"${2 * 4 + 3 * 3}" # computes to 33 +"${3 * 3 + 2 * 4}" # computes to 44 +"${(2 * 4) + (3 * 3)}" # computes to 17 +"${(3 * 3) + (2 * 4)}" # computes to 17 +```