AutoHotkey Community

It is currently May 27th, 2012, 3:45 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Arithmetic error
PostPosted: November 5th, 2005, 6:58 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
I vaguely remember, have not we discussed this already? Anyway, I thought both of these sums should evaluate to -1, but the first one gives 0.
Code:
MsgBox % -0x8000000000000000 + 0x7FFFFFFFFFFFFFFF
MsgBox % -0x7FFFFFFFFFFFFFFF + 0x7FFFFFFFFFFFFFFE


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 6th, 2005, 5:37 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
By pure chance, the problem occurs only for hex numbers, not for decimal numbers.

The problem comes about from the fact that unary minus is seen as an operator even when it's in front of a numeric literal. Therefore, 0x8000000000000000 was being passed to ATOI64() as a positive number, which (since it was too large) was capped to 0x7fffffffffffffff. Later, when the unary minus was finally applied, it was too late.

The best solution seems to be to collapse unary minus into a negative numeric literal at an early stage.

Thanks for reporting it. It will be fixed in the next update.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 3 guests


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