# Dec/Hex quirks

## Recommended Posts

Trying to understand how AutoIt converts between strings/numbers with Hex/Dec functions. I end up banging my head because of all these weird language quirks. Can someone explain to me why the first two cases work and the second two don't?

; we work

MsgBox(0, "Test: ", 0xAABBCC )

MsgBox(0, "Test: ", Dec("AABBCC") )

; we dont

MsgBox(0, "Test: ", Dec(0xAABBCC) )

MsgBox(0, "Test: ", Dec("0xAABBCC") )

##### Share on other sites

Correct syntax from helpfile:

`\$dec = Dec("FFFF");returns the number 65536`

To explain this, it's just the way they made autoit

Edit: typo

Edited by Wolvereness

Offering any help to anyone (to my capabilities of course)Want to say thanks? Click here! [quote name='Albert Einstein']Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.[/quote][quote name='Wolvereness' date='7:35PM Central, Jan 11, 2005']I'm NEVER wrong, I call it something else[/quote]

##### Share on other sites

Not exactly the answer I was hoping for..

##### Share on other sites

I'm unable to test, but I think you have to remove the 0x for use with Dec()..

##### Share on other sites

If a function is returning a hexidecimal number in 0xABCDEF format, just stringtrim the 0x off

Function returns a hex in variable \$hex

A StringTrimLeft(\$hex,2) would be your best bet then to convert it with the Dec() function.

Thus resulting in:

`Dec(StringTrimLeft(\$hex,2))`

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...