AutoHotkey Community

It is currently May 27th, 2012, 12:11 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 18 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: April 16th, 2011, 9:42 pm 
Offline

Joined: May 3rd, 2009, 7:16 pm
Posts: 345
Location: OH, USA
Great explanation Lexikos. One thing: Why can't number format be retained internally when floats are operated on? Or is this essentially what v2 does as v1 relies on SetFormat?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 17th, 2011, 2:01 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
Solar wrote:
Why can't number format be retained internally when floats are operated on?
What do you mean? 0.00 + 1 = 1.00? Well, 0.00 is a string. To perform math on it, AutoHotkey has to convert it into a number (i.e. in binary format). The output of any math operation is either an empty string (error) or a binary number (string format is irrelevant). Floating-point numbers are stored in binary form on both v1 and v2, but how you get a binary number in the first place differs slightly. Numeric literals in v1 are always SYM_OPERAND (which is either just a string, or a string with a cached binary integer), whereas numeric literals in v2 are either SYM_INTEGER (binary integer) or SYM_FLOAT (binary floating-point number).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 17th, 2011, 2:36 am 
Offline

Joined: May 3rd, 2009, 7:16 pm
Posts: 345
Location: OH, USA
I think I understand now. To return x as a string representation, you could do the following:
Code:
MsgBox % func()

func() {
    x := 1.0
    if (x) {
    }
    return x . ""
}

This is effectively the same as using return (x) in my old example because return (expression) "forces" an expression, thus, returning a string. But, as you said, the value returned wouldn't be a pure number. Please correct me if I'm misunderstanding this.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page Previous  1, 2

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group