You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`add` x y z ... | Returns x + y + z + ..., detects first number's type - is it _int_ or _float_ and based on that adds. (use `toFloat` on the first argument to force floating point math.)`{{add 5 4 3 2 -1}}` sums all these numbers and returns `13`. |
647
-
|`bitwiseAnd` x y | The output of bitwise AND is 1 if the corresponding bits of two operands is 1. If either bit of an operand is 0, the result of corresponding bit is evaluated to 0. Example: `{{bitwiseAnd 12 25}}` returns `8`, that in binary 00001100 AND 00011001 is 00001000. |
648
-
|`bitwiseAndNot` x y | This function is called bit clear because of AND NOT. For example in the expression z = x AND NOT y, each bit of z is 0 if the corresponding bit of y is 1; otherwise it equals to the corresponding bit of x. `{{bitwiseAndNot 7 12}}` returns `3`, that is 0111 AND NOT 1100 is 11. |
649
-
|`bitwiseNot` x | The bitwise NOT operator inverts the bits of the argument. Example: `{{bitwiseNot 7}}` returns `-8`. that in binary 0111 to 1000 |
650
-
|`bitwiseOr` x y z... | The output of bitwise OR is 1 if at least one corresponding bit of two operands is 1. Example: `{{bitwiseOr 12 25}}` returns `29`, that in binary 00001100 OR 00011001 is 00011101. |
651
-
|`bitwiseXor` x y | The result of bitwise XOR operator is 1 if the corresponding bits of two operands are opposite. Example: `{{bitwiseXor 12 25}}` returns `21`, that in binary 00001100 OR 00011001 is 00010101. |
652
-
|`bitwiseLeftShift` x y | Left shift operator shifts all bits towards left by a certain number of specified bits. The bit positions that have been vacated by the left shift operator are filled with 0. Example: `{{range seq 0 3}} {{bitwiseLeftShift 212 .}} {{end}}` returns `212 424 848`|
653
-
|`bitwiseRightShift` x y | Right shift operator shifts all bits towards right by certain number of specified bits. Example: `{{range seq 0 3}} {{bitwiseRightShift 212 .}} {{end}}` returns `212 106 53`. |
654
-
|`cbrt` x | Returns the cube root of given argument in type _float64_ e.g. `{{cbrt 64}}` returns `4`. |
655
-
|`div` x y z ... | Division, like `add` or `mult`, detects first number's type first. `{{div 11 3}}` returns `3` whereas `{{div 11.1 3}}` returns `3.6999999999999997`|
656
-
|`fdiv` x y z ... | Meant specifically for floating point numbers division. |
657
-
|`log` x (base) | Log is a logarithm function using (log base of x). Arguments can be any type of numbers, as long as they follow logarithm logic. Return value is of type _float64_. If base argument is not given It is using natural logarithm (base e - The Euler's constant) as default.`{{ log "123" 2 }}` will return `6.94251450533924`. |
658
-
|`mathConst` "arg" | Function returns all constants available in go's math package as _float64_. `"arg"` has to be a case-insensitive _string_ from [math constants list](https://pkg.go.dev/[email protected]#pkg-constants). For example `{{mathConst "sqrtphi"}}` would return `1.272019649514069`. |
659
-
|`max` x y | Returns the larger of x or y as type _float64_. |
660
-
|`min` x y | Returns the smaller of x or y as type _float64_. |
661
-
|`mod` x y | Mod returns the floating-point remainder of the division of x by y. For example, `mod 17 3` returns `2` as type _float64_.<br><br>Note that like Go's `[math.Mod](https://pkg.go.dev/math#Mod)` function, `mod` takes the sign of `x`, so `mod -5 3` results in `-2`, not `1`. To ensure a non-negative result, use `mod` twice, like such: `mod (add (mod x y) y) y`. |
662
-
|`mult` x y z ... | Multiplication, like `add` or `div`, detects first number's type. `{{mult 3.14 2}}` returns `6.28`|
663
-
|`pow` x y | Pow returns x\*\*y, the base-x exponential of y which have to be both numbers. Type is returned as _float64_. `{{ pow 2 3 }}` returns `8`. |
664
-
|`randInt` (stop, or start stop) | Returns a random integer between 0 and stop, or start - stop if two args are provided.Result will be `start <= random number < stop`. Without arguments, range is 0..10. Example in section's [Snippets](#math-sections-snippets). |
665
-
|`round` x | Returns the nearest integer, rounding half away from zero. Regular rounding > 10.4 is `10` and 10.5 is `11`. All round functions return type _float64_, so use conversion functions to get integers. For more complex rounding, example in section's [Snippets](#math-sections-snippets). |
666
-
|`roundCeil` x | Returns the least integer value greater than or equal to input or rounds up. `{{roundCeil 1.1}}` returns `2`. |
667
-
|`roundEven` x | Returns the nearest integer, rounding ties to even.<br>`{{roundEven 10.5}}` returns `10 {{roundEven 11.5}}` returns `12`. |
668
-
|`roundFloor` x | Returns the greatest integer value less than or equal to input or rounds down. `{{roundFloor 1.9}}` returns `1`. |
669
-
|`sqrt` x | Returns the square root of a number as type _float64_.<br>`{{sqrt 49}}` returns `7, {{sqrt 12.34 \|printf "%.4f"}} returns 3.5128`|
670
-
|`sub` x y z ... | Returns x - y -z - ... Works like add, just subtracts. |
671
-
672
-
### Math section's snippets
673
-
674
-
-`{{$d := randInt 10}}` Stores random _int_ into variable `$d` (a random number from 0-9).
675
-
- To demonstrate rounding float to 2 decimal places.\
0 commit comments