Round function not working

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
Snickers
Macro Veteran
Posts: 151
Joined: Thu Dec 09, 2004 3:01 pm
Location: Somewhere in TX

Round function not working

Post by Snickers » Thu Aug 02, 2007 9:35 pm

let>rightX=123
let>leftX=23

Let>length={Round(%rightX%-%leftX%)}
Let>size=%length%/10

message>%size%

I would expect this to return a message stating simply "10"
is this an incorrect way of using the round function?

Of course rounding isn't necessary in the expression above, however, in my expression for my script there may or may not be instances where rounding will be necessary. I am trying to write a script that will allow for both rounding with necessary and when unnecessary.

I am using version 7.4.008

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Thu Aug 02, 2007 9:43 pm

I think you're using round on the wrong result and with the numbers you posted there would be nothing to round since it would all be whole numbers.

try this instead:

let>rightX=123
let>leftX=21

Let>length=%rightX%-%leftX%
//length=102

Let>size={round(%length%/10)}
//102/10=10.2 size should be rounded to 10

message>%size%

Snickers
Macro Veteran
Posts: 151
Joined: Thu Dec 09, 2004 3:01 pm
Location: Somewhere in TX

Post by Snickers » Thu Aug 02, 2007 9:51 pm

Ack! jeez!

I have been writing this one so quickly today that I was trying to round my length, when I should have rounded my size.

In other words, i was trying to round my dividend instead of my quotient.

Thank you for straightening that one out!

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts