AHK has problem distinguishing hex numbers Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
serg
Posts: 56
Joined: 21 Mar 2015, 05:33

AHK has problem distinguishing hex numbers

Post by serg » 15 Sep 2019, 05:32

Hi folks,

I ran into some mysterious thing in AHK: when comparing 2 different hex numbers, ahk treats them as equal:

Code: Select all

q1 := "0xffffffffe90e1fe2"
q2 := "0xffffffff8fb50aba"
if (q1 = q2)
 msgbox, Equal
I got these numbers from Winexist() after creating 2 GUI's.
Any thoughts on what it means and how to deal with it?

User avatar
Nextron
Posts: 1391
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win10 AHK: Unicode x32

Re: AHK has problem distinguishing hex numbers  Topic is solved

Post by Nextron » 15 Sep 2019, 06:22

First of, your q1 and q2 are stored as strings.

However, it looks like the comparison works by comparing them as numbers, which overflow an Int64, resulting in two identical numbers (replace the most significant f to 0 to prevent the overflow and your code works as expected). To force the comparison as strings, concatenate a space to it like: if (q1 " " = q2 " ").

serg
Posts: 56
Joined: 21 Mar 2015, 05:33

Re: AHK has problem distinguishing hex numbers

Post by serg » 16 Sep 2019, 05:37

@Nextron

Appreciate! :thumbup:

Post Reply

Return to “Ask for Help (v1)”