Title: Playing with [calc]
Last modified: March 31, 2021

---

# Playing with [calc]

 *  [iantresman](https://wordpress.org/support/users/iantresman/)
 * (@iantresman)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/playing-with-calc/)
 * `[calc]` does not always work as expected. Here is what I found:
 *     ```
       (Set) [set years]377[/set]. OK (displays nothing)
       (get): [get years]. OK. (displays 377)
       + [calc]years + 10[/calc]. OK
       - [calc]years - 10[/calc]. Does not work
       - [calc]years + -10[/calc]. Workaround
       * [calc]years * 10[/calc]. OK
       / [calc]years / 10[/calc]. OK
       % [calc]years % 10[/calc]. Does not work (mod)
       ^ [calc]years ^ 10[/calc]. OK
       mod [calc]years mod 10[/calc].  Does not work
       mod [calc]years mod(10)[/calc]. Does not work
       mod [calc]mod(years,10)[/calc].  OK (modulo)
       ```
   
 * Other built in functions:
 * ‘sin’,’sinh’,’arcsin’,’asin’,’arcsinh’,’asinh’,
    ‘cos’,’cosh’,’arccos’,’acos’,’
   arccosh’,’acosh’, ‘tan’,’tanh’,’arctan’,’atan’,’arctanh’,’atanh’, ‘sqrt’,’abs’,’
   ln’,’log’,’exp’,’floor’,’ceil’. ie. `log(years)` will work.
 * Other functions:
 * ‘average’=>array(-1), ‘max’=>array(-1), ‘min’=>array(-1),
    ‘mod’=>array(2), ‘
   pi’=>array(0), ‘power’=>array(2), ’round’=>array(1, 2), ‘sum’=>array(-1), ‘rand_int’
   =>array(2), ‘rand_float’=>array(0), ‘format’=>array(-1) The number in brackets
   is the number of parameters. -1 is any number. e.g `[calc]rand_int(min,max)[/
   calc]` will display a random integer between min and max.
 * You can also use the constants: p() and exp(1).
    -  This topic was modified 5 years, 2 months ago by [iantresman](https://wordpress.org/support/users/iantresman/).
    -  This topic was modified 5 years, 2 months ago by [iantresman](https://wordpress.org/support/users/iantresman/).

Viewing 1 replies (of 1 total)

 *  Thread Starter [iantresman](https://wordpress.org/support/users/iantresman/)
 * (@iantresman)
 * [4 years, 11 months ago](https://wordpress.org/support/topic/playing-with-calc/#post-14689595)
 * Correction: You can also use the constants: **pi()** and exp(1).

Viewing 1 replies (of 1 total)

The topic ‘Playing with [calc]’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/custom-content-shortcode_766976.svg)
 * [Custom Content Shortcode](https://wordpress.org/plugins/custom-content-shortcode/)
 * [Support Threads](https://wordpress.org/support/plugin/custom-content-shortcode/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-content-shortcode/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-content-shortcode/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-content-shortcode/reviews/)

 * 1 reply
 * 1 participant
 * Last reply from: [iantresman](https://wordpress.org/support/users/iantresman/)
 * Last activity: [4 years, 11 months ago](https://wordpress.org/support/topic/playing-with-calc/#post-14689595)
 * Status: not resolved