Round function bug

General Macro Scheduler discussion

Moderators: Dorian (MJT support), JRL

schwander
Junior Coder
Posts: 29
Joined: Tue Jun 14, 2011 6:32 am

Round function bug

Post by schwander » Sat Feb 25, 2012 7:09 am

Hi
Please, check this out

Code: Select all

Let>a=3/2
Let>b={round(%a%)}
Mdl>%b%
There is error message appears.
Best regards.

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

Post by JRL » Sat Feb 25, 2012 7:36 am

Tried your code in versions 12 and 13 with no error. What version are you using?

schwander
Junior Coder
Posts: 29
Joined: Tue Jun 14, 2011 6:32 am

Post by schwander » Sat Feb 25, 2012 8:37 pm

Hello, Dick
Just look at this
Image
Best regards.

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sat Feb 25, 2012 9:06 pm

If I run this code I get a message box showing the value 2. Which is what I would expect (1.5 is rounded up to 2). I am using 13.1
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

schwander
Junior Coder
Posts: 29
Joined: Tue Jun 14, 2011 6:32 am

Post by schwander » Sat Feb 25, 2012 9:32 pm

Hi, Marcus
I am using 13.1
Do you mean 13.1.02 version?
What about my case?
And one more question:
What the difference between "Trunc" and "Drunk" :D (between "Trunc" and "Int") functions?
Last edited by schwander on Sun Feb 26, 2012 12:29 am, edited 1 time in total.

schwander
Junior Coder
Posts: 29
Joined: Tue Jun 14, 2011 6:32 am

Post by schwander » Sun Feb 26, 2012 12:28 am

Hello again,
So I'd found the source of the issue.
It appears when MS runs under some kind of Virtual Machines.
Host system and VMWare Workstation 7 are free from this "bug".
VirtualBox 4.1.8 and Parallels Workstation 6 are not.
So, MS's developers are rehabilitated. :)
But what the solution?...
Best regards.

schwander
Junior Coder
Posts: 29
Joined: Tue Jun 14, 2011 6:32 am

Post by schwander » Tue Feb 28, 2012 7:24 am

Hi,
I continue to study the issue.
As far as I know 2,5 and 4,5 and 6,5 must be rounded to 3 5 7
Am I wrong?
There is a result of MS calculations:
Image
Further, the bug described above has a relation to Virtual Machines.
I was mistaken when I'd claimed VMWare Workstation 7 is free from this problem.
Actually the error occurs only when script runs under MS main application. All is good when it is executed under MS's Editor launched as a standalone application or when the script starts directly from it's folder. I had investigated the issue on Parallels Workstation 6 and I guess it is related to Parallels Tools Service.

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Feb 28, 2012 10:47 am

The Round function uses "Bankers Rules". An exact half is rounded to the nearest even number.

http://blogs.msdn.com/b/ericlippert/arc ... nding.aspx

http://docwiki.embarcadero.com/VCL/en/System.Round
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

schwander
Junior Coder
Posts: 29
Joined: Tue Jun 14, 2011 6:32 am

Post by schwander » Tue Feb 28, 2012 12:27 pm

Hi,
Ok! I see now.
I suppose it would be useful to make help-file article about Round func more clear to understand (without "greatest absolute magnitude" term)
And thank you Marcus!
P.S.
Please, do something with issue I'd posted above. I don't like unpredictable results of MS calculations (I mean an accidential stop and error message).

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Feb 28, 2012 12:46 pm

Do you mean the problem in the first post? I assumed you had sorted that. Have you tried setting the decimal and thousand separators:

Let>DECIMAL_SEPARATOR=.
Let>THOUSAND_SEPARATOR=,
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

schwander
Junior Coder
Posts: 29
Joined: Tue Jun 14, 2011 6:32 am

Post by schwander » Tue Feb 28, 2012 5:16 pm

Hi,
I have tried to follow your advice, but unfortunately the issue hasn't been solved.
Config:
Parallels Workstation 6
Guest OS - Windows xp sp3

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Feb 28, 2012 5:20 pm

How are the regional settings set up in control panel (it shouldn't matter but ..)?

Have you tried setting the DECIMAL_SEPARATOR and THOUSAND_SEPARATOR the other way around? They should adopt the system settings.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

schwander
Junior Coder
Posts: 29
Joined: Tue Jun 14, 2011 6:32 am

Post by schwander » Tue Feb 28, 2012 7:39 pm

Hi,
The thing is the Round function sometimes (in some conditions) is executed correctly in others - not. I was unable to determine exactly what this error depends on. I just suppose it has relation to services provided by VM's manufacturer. It seems to me there is some conflict between services and MacroScheduler app.
So as you requested the regional settings are Russian.

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Wed Feb 29, 2012 4:53 am

A couple of comments:

1) Round in most languages can specify the desired number of dp's in the result. It would be nice to have that option. (Yes, I do know there are multiply/divide work arounds.)

2)
mtettmar wrote:The Round function uses "Bankers Rules". An exact half is rounded to the nearest even number.
Doesn't that conflict with the command reference "If X is exactly halfway between two whole numbers, the result is the number with the greatest absolute magnitude."?

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Feb 29, 2012 9:58 am

1. Will add to wish list.

2. Yes, sounds like a contradiction in the help file. Will get that sorted.

Also a possible enhancement for a future version is a flag to alter the default rounding system.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

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