Invalid floating point operation with round or trunc funct.

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
migro
Macro Veteran
Posts: 151
Joined: Thu Nov 06, 2003 5:23 pm
Location: Germany
Contact:

Invalid floating point operation with round or trunc funct.

Post by migro » Tue Jan 01, 2013 8:01 pm

Sorry Marcus,
used the wrong forum. Should have post it into: "Technical / Scripting". Can You please move it?

-----------------------------

When I execute the following (simplified) code, I get an error :"Invalid floating point operation".

Code: Select all

Let>Value=99
Let>Exp=10

Let>floatVar={(%Value%^%Exp%)-1}
mdl>Float: %floatVar%
Let>intVar={round (%floatVar%)}
mdl>Int: %intVar%
With exp=9 (9.13517247483642E17) no error is returned.
Seems that the error occures with numbers >= 1.00000000000000E19

Any idea how to avoid this error?
regards
migro

User avatar
migro
Macro Veteran
Posts: 151
Joined: Thu Nov 06, 2003 5:23 pm
Location: Germany
Contact:

Post by migro » Wed Jan 02, 2013 2:37 am

Think I know now, why an error is thrown here, after reading a little bit more about the round-function.
The floating point value is too big, so it can't be converted to an integer (result will exceed 19 digits...)

Am I right?
regards
migro

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 Jan 02, 2013 4:52 pm

Your code runs fine for me without error. What am I supposed to be seeing?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

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 Jan 02, 2013 6:32 pm

Could it be a 32 vs 64 bit OS issue? I have the same result as migro on Win7/32, exponent 9 works, exponent 10 results in "Invalid floating point operation".

User avatar
migro
Macro Veteran
Posts: 151
Joined: Thu Nov 06, 2003 5:23 pm
Location: Germany
Contact:

Post by migro » Wed Jan 02, 2013 7:51 pm

Hi together,

I got the error on both XPsp3 (x86) and Win7sp1 Ult (x64).
Please see attached screenshot.
Image
Screenshot was taken on a system with Win7 x64 and 6 GB RAM.
regards
migro

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 Jan 02, 2013 8:02 pm

So much for my theory :oops: What version of MacroScheduler?

User avatar
migro
Macro Veteran
Posts: 151
Joined: Thu Nov 06, 2003 5:23 pm
Location: Germany
Contact:

Post by migro » Wed Jan 02, 2013 8:15 pm

Version 13.2.4 - November 2012.
I think this was the latest one.
regards
migro

User avatar
Grovkillen
Automation Wizard
Posts: 1026
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Same here

Post by Grovkillen » Thu Feb 07, 2013 9:01 am

Okay, so I ran into this issue myself and when I copy/paste the code from the first post I get these two messages:

First message...
Image

Second message...
Image


EDIT: Version 14.0.2
Let>ME=%Script%

Running: 15.0.24
version history

User avatar
Grovkillen
Automation Wizard
Posts: 1026
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Post by Grovkillen » Thu Feb 07, 2013 9:19 am

Okay,

I've done some research and the problem is that my system use "," as decimal separator and the round function only work with "." as decimal separator. So I need to convert all the input data to "." from "," which is not very good... is it confirmed that the math functions ony work with "." ?
Let>ME=%Script%

Running: 15.0.24
version history

User avatar
Grovkillen
Automation Wizard
Posts: 1026
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Post by Grovkillen » Thu Feb 07, 2013 9:26 am

Code: Select all

Let>DECIMAL_SEPARATOR=.
Let>test_function=2.8*1.1
MDL>test_function
Let>what_to_round=1.8
Let>rounded_value={round(%what_to_round%)}
MDL>rounded_value

Let>DECIMAL_SEPARATOR=,
Let>test_function=2,8*1,1
MDL>test_function
Let>what_to_round=1,8
//not working
Let>rounded_value={round(%what_to_round%)}
MDL>rounded_value
Let>ME=%Script%

Running: 15.0.24
version history

User avatar
Grovkillen
Automation Wizard
Posts: 1026
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Post by Grovkillen » Mon Aug 19, 2013 2:40 pm

Any news regarding this?
Let>ME=%Script%

Running: 15.0.24
version history

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

Post by Marcus Tettmar » Mon Aug 26, 2013 3:24 pm

The math functions in complex expressions (between { and }) only support "." as decimal 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?

User avatar
Grovkillen
Automation Wizard
Posts: 1026
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Post by Grovkillen » Tue Aug 27, 2013 10:41 am

Yeah I learned this some time ago and even added a comment to the online reference guide (http://www.mjtnet.com/manual/index.html ... ctions.htm). Maybe this should be added to the offline help file as well?

Even better, please make it work with other than "." in the future. :)
Let>ME=%Script%

Running: 15.0.24
version history

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 Aug 27, 2013 12:25 pm

We can't make complex expressions work with "," as the decimal separator because it is already the parameter separator. This is common to almost all programming languages. Because "," is the parameter delimiter "." has to be the decimal placeholder.

Outside of Complex Expressions Macro Scheduler obeys regional settings by default, but inside VBScript and Complex Expressions this is not possible.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

User avatar
Grovkillen
Automation Wizard
Posts: 1026
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Post by Grovkillen » Tue Aug 27, 2013 1:25 pm

Thanks Marcus for the information. Future realeases maybe could have a more clear Error message? "Couldn't read string as float" is not enough for me to understand (in the beginning before you enlightened me) that "," was causing the problem...
Let>ME=%Script%

Running: 15.0.24
version history

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