Sign in to follow this  
Followers 0
dcyuri7

Core type conversion

7 posts in this topic

#1 ·  Posted (edited)

Basically, i have a hex value ("9B13") and when i convert it to decimal using 'Dec()', it returns this: 39699. I have a trainer program with a built in data-type converter(no source provided), and in some way(i'm guessing unsigned/reversed) this resulting number equates to: 5019. I need to know how, does anyone have any ideas? I am extremely stumped here.

I briefly researched unsigned integer data types, and because the basic int(& C++ long)'s range is −32,768 to +32,767, and this number is above that, assuming I convert to unsigned it should cap and revert to 5019(I'm guessing), and I direly need an algorithm for this.

Edited by dcyuri7

Share this post


Link to post
Share on other sites



Basically, i have a hex value ("9B13") and when i convert it to decimal using 'Dec()', it returns this: 39699. I have a trainer program with a built in data-type converter(no source provided), and in some way(i'm guessing unsigned/reversed) this resulting number equates to: 5019. I need to know how, does anyone have any ideas? I am extremely stumped here.

I briefly researched unsigned integer data types, and because the basic int(& C++ long)'s range is −32,768 to +32,767, and this number is above that, assuming I convert to unsigned it should cap and revert to 5019(I'm guessing), and I direly need an algorithm for this.

Well, Dec("139B") = 5019, without resorting to complements math. It's simply byte reversed, or a different "endianess".

AutoIt's integers are INT32, plus INT64 in the Win64 compile option.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Well, Dec("139B") = 5019, without resorting to complements math. It's simply byte reversed, or a different "endianess".

AutoIt's integers are INT32, plus INT64 in the Win64 compile option.

:)

$hex="9B13"
    $dec=Dec(_StringReverse($hex))
    MsgBox(0,"b","Decimal value is(Orig: "&$hex&"): "&$dec)

When I run this, the result is 12729. I'm guessing it's automatically assuming 32bit mode?(hence the xxxx vs xxxx0000)?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

*sigh* well if anyone does know what I'm doing wrong with this, please don't hesitate to let me know. I'll keep playing around with it until then. :)

*edit

wasted an entire day on this. im just going to go learn C++. this is too ungodly tedious.

Edited by dcyuri7

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Alright Auto it is Great, believe me when I say this, I love this program. But I have one major suggestion, that needs addressing. Please add the ability to type cast! I need full control of ushort int long double float char byte all that good stuff.(or equivelant functions other than 'Dec' and 'Hex') I need it direly! I am having to goto C++ cause AI3 doesn't offer it! >.<

Edited by dcyuri7

Share this post


Link to post
Share on other sites

$hex="9B13"
    $dec=Dec(_StringReverse($hex))
    MsgBox(0,"b","Decimal value is(Orig: "&$hex&"): "&$dec)

When I run this, the result is 12729. I'm guessing it's automatically assuming 32bit mode?(hence the xxxx vs xxxx0000)?

You are not understanding the difference between little and big endian. The bytes are swapped, not the hex characters (which are only 4bits each). So 0x9B13 does not become 0x31B9, which is the effect of your StringReverse, rather it's 0x139B.

If you don't get that, it is hard to see what you'll be able to do with low level type casting in AutoIt. If you must, I believe you can create such structures in DllStructCreate(), DllStructSetData(), and DllStructGetData().

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

*edit

wasted an entire day on this. im just going to go learn C++. this is too ungodly tedious.

Good idea...

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0