| View previous topic :: View next topic |
| Author |
Message |
Benny-D
Joined: 29 Feb 2008 Posts: 865
|
Posted: Sun Mar 14, 2010 12:31 am Post subject: Deducting 2 (integer) from a float number 005 |
|
|
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 |
|
 |
jaco0646
Joined: 07 Oct 2006 Posts: 3113 Location: MN, USA
|
Posted: Sun Mar 14, 2010 12:40 am Post subject: |
|
|
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 |
|
 |
Benny-D
Joined: 29 Feb 2008 Posts: 865
|
Posted: Sun Mar 14, 2010 12:49 am Post subject: |
|
|
| Thank you very much, jaco0646! |
|
| Back to top |
|
 |
None
Joined: 28 Nov 2009 Posts: 3086
|
Posted: Sun Mar 14, 2010 12:58 am Post subject: |
|
|
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.
| 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 |
|
 |
Benny-D
Joined: 29 Feb 2008 Posts: 865
|
Posted: Sun Mar 14, 2010 1:21 am Post subject: |
|
|
Aaaaaaaaah!
Tha was the problem! Thank you, None!
How did you notice it? |
|
| Back to top |
|
 |
None
Joined: 28 Nov 2009 Posts: 3086
|
Posted: Sun Mar 14, 2010 1:46 am Post subject: |
|
|
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.  |
|
| Back to top |
|
 |
Benny-D
Joined: 29 Feb 2008 Posts: 865
|
Posted: Sun Mar 14, 2010 7:35 am Post subject: |
|
|
| 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 |
|
 |
|