From f62796cb2a864d3dff090ad7d0b107d825edadc2 Mon Sep 17 00:00:00 2001 From: vastep <47853508+vastep@users.noreply.github.com> Date: Thu, 4 May 2023 22:14:58 +0300 Subject: [PATCH 1/3] Add Float Math functions Signed-off-by: vastep <47853508+vastep@users.noreply.github.com> --- .../chart_template_guide/function_list.md | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/content/en/docs/chart_template_guide/function_list.md b/content/en/docs/chart_template_guide/function_list.md index 69baebd0b..71d828f5d 100644 --- a/content/en/docs/chart_template_guide/function_list.md +++ b/content/en/docs/chart_template_guide/function_list.md @@ -1811,6 +1811,74 @@ Returns the length of the argument as an integer. len .Arg ``` +## Float Math Functions + +All math functions operate on `float64` values. + +### addf + +Sum numbers with `addf` + +This will return `5.5`: + +``` +addf 1.5 2 2 +``` + +### add1f + +To increment by 1, use `add1f` + +### subf + +To subtract, use `subf` + +This is equivalent to `7.5 - 2 - 3` and will return `2.5`: + +``` +subf 7.5 2 3 +``` + +### divf + +Perform integer division with `divf` + +This is equivalent to `10 / 2 / 4` and will return `1.25`: + +``` +divf 10 2 4 +``` + +### mulf + +Multiply with `mulf` + +This will return `6`: + +``` +mulf 1.5 2 2 +``` + +### maxf + +Return the largest of a series of floats: + +This will return `3`: + +``` +maxf 1 2.5 3 +``` + +### minf + +Return the smallest of a series of floats. + +This will return `1.5`: + +``` +minf 1.5 2 3 +``` + ## Network Functions Helm has a single network function, `getHostByName`. From 6d5817b9b1be9e8b57681606434a8562b5c8e8e5 Mon Sep 17 00:00:00 2001 From: vastep <47853508+vastep@users.noreply.github.com> Date: Fri, 5 May 2023 08:54:30 +0300 Subject: [PATCH 2/3] Update TOC Signed-off-by: vastep <47853508+vastep@users.noreply.github.com> --- content/en/docs/chart_template_guide/function_list.md | 1 + 1 file changed, 1 insertion(+) diff --git a/content/en/docs/chart_template_guide/function_list.md b/content/en/docs/chart_template_guide/function_list.md index 71d828f5d..b1c12556e 100644 --- a/content/en/docs/chart_template_guide/function_list.md +++ b/content/en/docs/chart_template_guide/function_list.md @@ -16,6 +16,7 @@ They are listed here and broken down by the following categories: * [Logic and Flow Control](#logic-and-flow-control-functions) * [Lists](#lists-and-list-functions) * [Math](#math-functions) +* [Float Math](#float-math-functions) * [Network](#network-functions) * [Reflection](#reflection-functions) * [Regular Expressions](#regular-expressions) From 58200d9c0e163acef008fe70b0cfa5b765aaafa2 Mon Sep 17 00:00:00 2001 From: vastep <47853508+vastep@users.noreply.github.com> Date: Fri, 5 May 2023 09:00:23 +0300 Subject: [PATCH 3/3] Re-order functions Signed-off-by: vastep <47853508+vastep@users.noreply.github.com> --- .../chart_template_guide/function_list.md | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/content/en/docs/chart_template_guide/function_list.md b/content/en/docs/chart_template_guide/function_list.md index b1c12556e..99fdcf6f6 100644 --- a/content/en/docs/chart_template_guide/function_list.md +++ b/content/en/docs/chart_template_guide/function_list.md @@ -1785,25 +1785,6 @@ Return the smallest of a series of integers. `min 1 2 3` will return `1`. -### floor - -Returns the greatest float value less than or equal to input value. - -`floor 123.9999` will return `123.0`. - -### ceil - -Returns the greatest float value greater than or equal to input value. - -`ceil 123.001` will return `124.0`. - -### round - -Returns a float value with the remainder rounded to the given number to digits -after the decimal point. - -`round 123.555555 3` will return `123.556`. - ### len Returns the length of the argument as an integer. @@ -1880,6 +1861,25 @@ This will return `1.5`: minf 1.5 2 3 ``` +### floor + +Returns the greatest float value less than or equal to input value. + +`floor 123.9999` will return `123.0`. + +### ceil + +Returns the greatest float value greater than or equal to input value. + +`ceil 123.001` will return `124.0`. + +### round + +Returns a float value with the remainder rounded to the given number to digits +after the decimal point. + +`round 123.555555 3` will return `123.556`. + ## Network Functions Helm has a single network function, `getHostByName`.