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 

Does "Round(Number [, N])" accept a variable for &

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
ggirf14



Joined: 01 Nov 2005
Posts: 96
Location: Ottawa

PostPosted: Fri Jun 15, 2007 12:43 am    Post subject: Does "Round(Number [, N])" accept a variable for & Reply with quote

My plan is :
Var1 = 17.00
4000.00 / Var1 = %x%
Round(%x% [, 2])
MsgBox, %x%
I am expecting in the result 200
for the following logic:

4000 / 17.00 = 235.29411764705882352941176470588 ; This is %x%
Round(%x% [, 2]) ; should round this up to 200???
Where do I go wrong
Code:
Var1 = 17.00
Var2=4000
EnvDiv, Var2, Var1 ;,Round(%Var2% ,1)
Round(%Var2% ,1)
MsgBox, %Var2%
Back to top
View user's profile Send private message
Jon



Joined: 28 Apr 2004
Posts: 373

PostPosted: Fri Jun 15, 2007 1:01 am    Post subject: Reply with quote

AHK Help wrote:
Round(Number [, N]): If N is omitted or 0, Number is rounded to the nearest integer. If N is positive number, Number is rounded to N decimal places. If N is negative, Number is rounded by N digits to the left of the decimal point. For example, Round(345, -1) is 350 and Round (345, -2) is 300. Unlike Transform Round, the result has no .000 suffix whenever N is omitted or less than 1. In v1.0.44.01+, a value of N greater than zero displays exactly N decimal places rather than obeying SetFormat. To avoid this, perform another math operation on Round()'s return value; for example: Round(3.333, 1)+0.


Code:
MsgBox, % Round(4000/17,-2)
Back to top
View user's profile Send private message Send e-mail
ggirf14



Joined: 01 Nov 2005
Posts: 96
Location: Ottawa

PostPosted: Fri Jun 15, 2007 1:12 am    Post subject: Reply with quote

Thank You! Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   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