Switch.Calculcation

Post Reply
diguimfodera
Newbie
Posts: 16
Joined: Thu Jan 21, 2016 1:34 am

Switch.Calculcation

Post by diguimfodera »

Please, I need to know how to make round up math calculations.
I need divide number for 4 and I need Integer number for result, round up it if necessary.
Example: 30/4 = 7,5 (but for number of copies It must be = 8)
User avatar
gabrielp
Advanced member
Posts: 645
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: Switch.Calculcation

Post by gabrielp »

Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
sander
Advanced member
Posts: 274
Joined: Wed Oct 01, 2014 8:58 am
Location: The Netherlands

Re: Switch.Calculcation

Post by sander »

Math.ceil will do;

Code: Select all

quantity = Math.ceil((origQuantity+extra)/nUp);
essexmate
Member
Posts: 30
Joined: Tue Sep 05, 2017 4:41 pm

Re: Switch.Calculcation

Post by essexmate »

I my case I had to divide number of pages by 2, but also needed the number to be rounded up if the number of pages was odd. I used the following:

Code: Select all

[Switch.Calculation:Expression="round([Stats.NumberOfPages]/2)"]
Post Reply