AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Deducting 2 (integer) from a float number 005

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Benny-D



Joined: 29 Feb 2008
Posts: 865

PostPosted: Sun Mar 14, 2010 12:31 am    Post subject: Deducting 2 (integer) from a float number 005 Reply with quote

How can I deduct 2 from a variable containing 005 float number?
I've tried it here, but it doesn't work:
Code:
CheckCounter = 5
SetFormat, Float, 03 ; making it 3-number format
CheckCounter += 0.0
msgbox, CheckCounter: %CheckCounter%
SetFormat, Float, 03 ; making it 3-number format
Counter :=  CheckCounter – 2
msgbox, here is the result: %Counter%
Back to top
View user's profile Send private message
jaco0646



Joined: 07 Oct 2006
Posts: 3113
Location: MN, USA

PostPosted: Sun Mar 14, 2010 12:40 am    Post subject: Reply with quote

You need to subtract a floating point number for SetFormat, Float to take effect; also you only need to specify the format once, since you're in the auto-execute section.
Code:
CheckCounter = 5
SetFormat, Float, 03 ; making it 3-number format
CheckCounter += 0.0
msgbox, CheckCounter: %CheckCounter%

Counter :=  CheckCounter - 2.0
msgbox, here is the result: %Counter%
Back to top
View user's profile Send private message Visit poster's website
Benny-D



Joined: 29 Feb 2008
Posts: 865

PostPosted: Sun Mar 14, 2010 12:49 am    Post subject: Reply with quote

Thank you very much, jaco0646!
Back to top
View user's profile Send private message
None



Joined: 28 Nov 2009
Posts: 3086

PostPosted: Sun Mar 14, 2010 12:58 am    Post subject: Reply with quote

also you posted it with – (a horizontal line) instead of - ( a Hyphen)
They look the same to you but the computer doesn't think so. Very Happy

Code:
CheckCounter = 5
SetFormat, FloatFast, 03 ;You could also use FloatFast
CheckCounter += 0.0
msgbox, CheckCounter: %CheckCounter%
Counter :=  CheckCounter - 2 ;and leave the 2 alone
msgbox, here is the result: %Counter%
Back to top
View user's profile Send private message
Benny-D



Joined: 29 Feb 2008
Posts: 865

PostPosted: Sun Mar 14, 2010 1:21 am    Post subject: Reply with quote

Aaaaaaaaah!
Tha was the problem! Thank you, None!
How did you notice it?
Back to top
View user's profile Send private message
None



Joined: 28 Nov 2009
Posts: 3086

PostPosted: Sun Mar 14, 2010 1:46 am    Post subject: Reply with quote

I noticed that the Expression was not giving the expected results. I tried a few thing and finaly narrowed it down to that. The – is also slightly longer than -.
The Expression treated It like a period in Concatenate. Shocked
Back to top
View user's profile Send private message
Benny-D



Joined: 29 Feb 2008
Posts: 865

PostPosted: Sun Mar 14, 2010 7:35 am    Post subject: Reply with quote

None wrote:
I noticed that the Expression was not giving the expected results. I tried a few things and finally narrowed it down to that.
Oh, I see. That's just great! Thank you.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group