function Int strange behaviour

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
Djek
Pro Scripter
Posts: 147
Joined: Sat Feb 05, 2005 11:35 pm
Location: Holland
Contact:

function Int strange behaviour

Post by Djek » Thu Nov 03, 2016 3:12 pm

hi all,

for label calculating i must create a checksum from number.

but i notice that sometimes the function integer (int) is behaving different...?

this is the code:

Code: Select all

let>varA=91
//varA=91
let>varB=%varA%/10
//varb=9.1
let>varC={int(%varB%)}
//varC=9
let>varD=%varB%-%varC%
//should be: 9.1 minus 9 =0.1 
//but result is varD=0.099999999999

as result varD i should get 0.1
but the calculation makes it 0.099999999
Is this also when you try it on your versions of MS ?

Why is this behaviour and how do i solve this ?

kind regards,
Djek

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

Re: function Int strange behaviour

Post by Marcus Tettmar » Thu Nov 03, 2016 4:11 pm

Odd. I'm investigating why this is. In the mean time you could do:

Format>%.1n,varD,res
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
Djek
Pro Scripter
Posts: 147
Joined: Sat Feb 05, 2005 11:35 pm
Location: Holland
Contact:

Re: function Int strange behaviour

Post by Djek » Fri Nov 04, 2016 10:28 am

thanks, Marcus,

the Format command solved the odd glitch,

kind regards,
Djek

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