Skip to content

terminal – convert or parse float to int in applescript fails in several ways

  • by

We have:

number_of_iterations=$((MINUTES_UNTIL_ASK_TO_CLOSE * 60 / 5))

There are a couple of weird behaviors when doing that.

Firstly, the result should be:

number_of_iterations = 0,2 * 60 / 5 = 2,4

However, the output of: echo "number_of_iterations" $((MINUTES_UNTIL_ASK_TO_CLOSE * 60 / 5)) is:


Secondly, I want to use it in the loop for ((a=1; a<=$number_of_iterations; a++)); do, it should be an integer. So actually the final desired output is:


How to do this this rounding of variables of float to int in applescript correctly?

I’ve tried the following, but it crashes the script:

echo "number_of_iterations" $((round(MINUTES_UNTIL_ASK_TO_CLOSE * 60 / 5))

Leave a Reply

Your email address will not be published. Required fields are marked *