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 

Transform problem

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Bug Reports
View previous topic :: View next topic  
Author Message
[二oO也



Joined: 22 Feb 2005
Posts: 60
Location: Sweden

PostPosted: Wed Feb 23, 2005 8:52 pm    Post subject: Transform problem Reply with quote

As I and Dippy46 mentioned at http://www.autohotkey.com/forum/viewtopic.php?t=2499, the Transform, Ouputvar, Round, %Inputvar%, 1 don't seem to work correctly. Sad
I tried to get rid of some zero-decimals, but Transform didn't change anything on the number.
Ex:
12.300000
should become
12.3
but still was
12.300000
_________________
"Make everything as simple as possible, but not simpler."
- Albert Einstein (1879-1955)
Back to top
View user's profile Send private message Visit poster's website
jonny



Joined: 13 Nov 2004
Posts: 3004
Location: Minnesota

PostPosted: Wed Feb 23, 2005 8:59 pm    Post subject: Reply with quote

It's working fine. It doesn't claim to remove trailing zeros. Use one of the other methods mentioned in the thread you linked. What this function does is round it to the nearest specified place. For instance take this script:

Code:
transform,outputvar,round,12.300000,1
msgbox,%outputvar%
return


It shows, like you said, 12.300000. Now take this script:

Code:
transform,outputvar,round,12.300001,1
msgbox,%outputvar%
return


Surprise, surprise! The output of this is, again, 12.300000. You see, it actually is working as documented and I can't find where it says it removes trailing zeros. It's supposed to do it this way because it's not meant to mess with the format of the number, it's meant to mess with the content of the number.
Back to top
View user's profile Send private message
[二oO也



Joined: 22 Feb 2005
Posts: 60
Location: Sweden

PostPosted: Wed Feb 23, 2005 10:09 pm    Post subject: Reply with quote

OK, well everyone makes mistakes. Embarassed
So, what do you suggest?
Something like BoBo's suggestion?
_________________
"Make everything as simple as possible, but not simpler."
- Albert Einstein (1879-1955)
Back to top
View user's profile Send private message Visit poster's website
jonny



Joined: 13 Nov 2004
Posts: 3004
Location: Minnesota

PostPosted: Wed Feb 23, 2005 10:32 pm    Post subject: Reply with quote

Hey, if it works, eh? Smile
Back to top
View user's profile Send private message
Dippy46



Joined: 06 Jul 2004
Posts: 171
Location: Manchester, England.

PostPosted: Fri Feb 25, 2005 1:05 am    Post subject: Reply with quote

@[二oO也
Sir you were quite correct in your asumptions. This command IS supposed to display your variable to the number of places you dictate.
However this command along with certain others is currently malfunctioning. For those of you who do not understand how this function is supposed to operate,I suggest you performm the same operation in AutoIt3 where the functioning IS working as documented. As I mentioned in a previous post, I'm hoping Chris will pick up on this and clarify the current position.
QED.......
_________________
Simple ideas lie within reach, only of complex minds
Back to top
View user's profile Send private message
jonny



Joined: 13 Nov 2004
Posts: 3004
Location: Minnesota

PostPosted: Fri Feb 25, 2005 1:18 am    Post subject: Reply with quote

While you may be partially correct, this does not qualify as a bug. Here is a quote from the documentation of AU3's Round function:

Quote:
and note that decimalplaces will never pad a number with trailing zeros.


This specifically states that it will never return a number with trailing zeros. In contrast, here is the entirety of AHK's Transform, Round documentation:

Quote:
If N is omitted, OutputVar will be set to Value1 rounded to the nearest integer. If N is positive number, Value1 will be rounded to N decimal places. If N is negative, Value1 will be rounded by N digits to the left of the decimal point. For example, -1 rounds to the ones place, -2 rounds to the tens place, -3 rounds to the hundreds place, etc.


Nowhere does it say that it will deal with trailing zeros. I must assume that Chris has never thought of this, since usually numbers don't have trailing zeros when they are processed by this command. It does sound like a plausible improvement, but it is indeed working as currently documented, so this request would be more in place in the Wishlist section than Bug Report.

I might note that just because something's working in AutoIt3 doesn't mean it will work in AutoHotkey. AutoIt3 has matured more in the area of mathematical operations, and it is more suited for those kind of tasks. The same can also be said for AutoHotkey in the area of hotkeys. The members of AutoIt3's forum would be piqued if you suddenly demanded why there was no support for single-key hotkeys. Razz
Back to top
View user's profile Send private message
Dippy46



Joined: 06 Jul 2004
Posts: 171
Location: Manchester, England.

PostPosted: Fri Feb 25, 2005 3:44 am    Post subject: Reply with quote

Laughing Laughing Laughing
Yeh OK, I'll concede (a little bit). In all fairness it's how I would have expected it to operate rather than how it does operate.
_________________
Simple ideas lie within reach, only of complex minds
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Fri Feb 25, 2005 2:22 pm    Post subject: Reply with quote

To force rounding to a specific decimal place, you can use SetFormat as in this example:
SetFormat, float, 0.1 ; Always round floating point numbers to one decimal place.

To clarify, I've added the following to "Round" in the documentation:
Quote:
Note: Round does not remove trailing zeros when rounding decimal places. For example, 12.333 rounded to one decimal place would become 12.300000. This behavior can be altered by using SetFormat prior to the operation (in fact, SetFormat may eliminate the need to use Round in the first place).
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Bug Reports 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