Jump to content
Sign in to follow this  
kpmwrestler

String to actual binary

Recommended Posts

kpmwrestler

Hey everyone, i have a quick question.

I am trying to convert characters, like an uppercase A for example, into binary. but the function StringToBinary converts it into hex! I want it in 1's and 0's like A in ascii would be 01000001, thats what i want is something like 01000001

is there a way to get that type of binary?

Share this post


Link to post
Share on other sites
PsaltyDS

Hey everyone, i have a quick question.

I am trying to convert characters, like an uppercase A for example, into binary. but the function StringToBinary converts it into hex! I want it in 1's and 0's like A in ascii would be 01000001, thats what i want is something like 01000001

is there a way to get that type of binary?

StringToBinary() does return a binary, just because it is presented in hex if ConsoleWrite() or MsgBox() the variable doesn't mean the variable contains textual hex characters.

:mellow:


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
LarryDalooza

A Hexadecimal pair like AA or D3 is a (widely accepted) character representation of the how the Bits are stored in a Byte. If you want to represent Bytes as Bits I am sure there are UDFs created for such things.

all of this is off the top of my head. I may be wrong... seeing as there is nothing on top of my head.

Lar.


f_mrcleansmalm_77ce002.jpgAutoIt has helped make me wealthy

Share this post


Link to post
Share on other sites
PsaltyDS

I may be wrong... seeing as there is nothing on top of my head.

Lar.

No, you were right... there's nothing on top of your head.

:mellow:


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
PsaltyDS

I didn't really get you but why does it return hex instead of 0's and 1's? And yeah, what is the purpose of the '0x' in front of all the 'binary' values produced?

Thank you!

The binary variant is not stored as "0xFEDCBA9876543210" in memory, of course. When you tell AutoIt to display a binary variant it has to convert it into something the user can read on a monitor. By far the most common convention for doing that is as hexadecimal ASCII characters with "0x" in front to flag the formatting used. You have to flag the format because 100 for example is indeterminate. If it's binary 100 = 410. For octal 100 = 6410. For hexadecimal 100 = 25610. AutoIt only has a convenient flag for hex, which is "0x" by industry standard.

Wanna' bend your head? Try this from the command line shell on your Windows box:

SET /a X = 010 * 2
SET /a X = 10 * 2
SET /a X = 0x10 * 2

In the shell environment, a leading zero makes it octal, a leading "0x" makes it hex, and not having those flags makes it decimal.

I doesn't matter whether you think it the most logical way to do things, it's the common convention.

:mellow:


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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.