HomeTaskerMaths in Tasker

Maths in Tasker

Make integers great again!

One of the Tasker functions that aren’t often talked about is the ability to do Maths in Tasker. ‘Do Maths‘ box in Variable Set action turns Tasker into a little Einstein or Alan Turing (because I hang around Manchester too much). This write-up aims to shed some light, and go beyond the basic mathematics, should you ever need it.

Maths in Tasker

Apart from basic operators, the list of mathematical expressions is rather impressive and it’s unlikely you will ever need all of them. To make an operation simply use Variable Set action and select the ‘do Maths’. Now you can write the equation of your choice.

Let’s try something simple:


The Internet believes that solving this little task makes you a genius. I’m pretty sure I know how we all feel about all these people bragging about their “maths skills”. I’m using it to illustrate that Tasker will obey mathematical rules when writing your calculations. To get an 8 you have to do this instead:


Maths in Tasker allows you to use more complicated algebra and substitute the values with variables as well!


This time we get the 8. Let’s get to my favourite part…

Ceil, floor, nextup… making the integers great again!

The weather forecast in my Weather Notification Project comes as a floating-point number (number with a decimal space). This level of precision is not that important.  I doubt I would feel the difference between 15°C and 15.87633°C. Here is how to get rid of the decimal quickly:

Variable Set %floor: floor(%temp)
Variable Set %ceil: ceil(%temp)
Variable Set %nextup: nextup(%temp)

As you can see that was quick and painless.

  • ceil() rounds up
  • floor() does the opposite
  • nextup() gets rid of the long decimal number

But this is a single operation only. What if I have an entire array of data to process? Regardless of the calculation, you want to apply – you can do it with a FOR loop:


FOR Loop
 A1: For [ Variable:%domaths Items:%Array() ] 
 A2: Variable Set [ Name:%result To:ceil(%domaths) 
     Recurse Variables:Off Do Maths:On Append:Off ] 
 A3: Array Push [ Variable Array:%new_array 
     Position:3 Value:%result Fill Spaces:On ] 
 A6: End For
 A7: Flash: %new_array

Each value from the %Array is iterated and the calculation (A2) is performed. The %result is assigned back to the %new_array in the same order.  It’s worth noting that you either have to ‘push‘ the values from the ‘bottom‘ of the array or use action Array Process – Reverse to restore the original order.

Other most used functions

Maths in Tasker has more functions, but I’m only going to cover most used by me. Let’s try modulus next. If you are new to programming it might be the first time you come across this:

Variable set: 16/7
Variable set: 16%7

Unlike divide, modulus gives your the reminder from the divide operation. You can ‘fit’ two sevens inside 16 and you get the reminder:2 It’s great to check if a number is even or odd (divide by 2 – if % = 0 it is an even number).

Absolute value gives you a positive value of the integer:

Variable Set: abs(-10)
Variable Set: abs(10)

Great for all the pesky situations where the value given is below 0.

More Maths in Tasker

A few more operations are available in Tasker. Variable Convert does number conversions for you. You can:

  • convert units,
  • time,
  • characters
  • deal with HTML tags
  • more…

Take a look at this list:

AutoTools Maths

The plugin AutoTools also contains action for mathematical calculations. These can be calculated in vanilla Tasker using more complicated equations but if you feel lazy feel free to use the plugin to:

  • calculate sum
  • calculate an average
  • find min/max number

AutoTools WebScreens Calculations

A new update to AutoTools introduced calculations to Web Screens. The option allows to assign multiple fields for inputs and outputs and perform a mathematical function on values. It’s a very fast and convenient way to create calculated fields and process the multiple fields at once (arrays).


I hope this opens up some new possibilities for you. Maths in Tasker is worth knowing, as it will save you from writing multiple actions to achieve the same result. It’s good to know the basics as it will surely make your life easier. If you have any other interesting maths tricks in Tasker, let me know in this Reddit thread.


Nothing says "Thank you" better than keeping my coffee jar topped up!


Support me on Patreon and get an early access to tutorial files and videos.


Bitcoin (BTC)

Use this QR to keep me caffeinated with BTC: 1FwFqqh71mUTENcRe9q4s9AWFgoc8BA9ZU

New to Tasker?

Tasker Quick Start – Getting started with Tasker

From newb to not so newbie in 10 min

Best Tasker Projects

How to use Raspberry PI as WOL (wake on lan) server

While you could wake up your PC from a mobile directly, having a dedicated server capable of doing so is the best solution. The reason is simple. You can hook up as many devices as you wish with a single endpoint. This is why Raspberry Pi is perfect for this.

How to wake on LAN computers and put it to sleep with Power Menu,...

How to Wake on LAN properly via Android, Alexa, Google Assistant and Web

7 awesome Bluetooth keyboard shortcuts for Android

7 unique Android shortcuts that you can add to any Bluetooth keyboard.

Smart overnight charging with Tasker

Still keeping your phone plugged in overnight? Try smarter overnight charging with this profile

One thing that Join app can’t do and how to fix it with Tasker

It's not possible to share the clipboard automatically between join accounts registered to 2 different emails. But you can fix this with tasker.

Essential Guides

Tasker: Seconds into DD:HH:MM:SS (dynamic)

It's time to.... ok it's a pun, but I will show you how to master time and convert seconds to DD:HH:MM:SS dynamically

4 ways to organise Tasker projects

Keep your Tasker tidy!

A better way to store Tasker credentials

The more clever way of managing credentials

Annoyed with dozens of AutoApps populating your app drawer? Here is a fix!

Clear your app drawer from the clutter in seconds

Putting AutoTools pie chart to a good use – SSID logger

Who wants a piece of the pie (chart)?