hex

Comparing Char which holds hex values C++

Hi, in C++ I have two chars holding hex values e.g.: char t = 0x4; char q = 0x4; How would i compare if the two values held in the char are the same?? I tried if (t == q) // should give me true but no, any help, thanks! ...

Check if Char is in range

Hi, if I have a range of say 000080-0007FF and I want to see if a char containing hex is within that range, how can I do this? Thanks a lot. Example char t = 0xd790; if (t is within range of 000080-0007FF) // true Thanks ...

Output ASCII Value C++

Hi, If I have a char which holds a hex value such has 0x53, (S), how can I display this as "S"? Code: char test = 0x53; cout << test << endl; Thanks! ...

Send binary to the serial port

To send a serial string character to the serial port. I would need to call WriteFile(handle, "A", strlen("A"), ...) However, what if I want to specify and send a hex or binary number? For example, I want to send WriteFile(handle, 0x41, sizeOf(0x41), ...) ? Is there a function that allow me to do this? ...

inserting hex value into mysql

Can there any way to insert a hex value into MYSQL? I also want to be able to retreive it in hex form. For example, something like: INSERT INTO table ( hexTag ) VALUES ( HEX(0x41) ); And if I do this, I want it to put an 'A' into the table ...

Why is Java able to store 0xff000000 as an int?

An integer's max value in Java is 2147483647, since Java integers are signed, right? 0xff000000 has a numeric value of 4278190080. Yet I see Java code like this: int ALPHA_MASK = 0xff000000; Can anyone enlighten me please? ...

Convert hex string to byte array

As indicated in the answers, this is a duplicate of "How do you convert Byte Array to Hexadecimal String, and vice versa, in C#?" Hi, Can we converting a hex string to a byte array using a built-in function in C# or I have to make a custom method for this? ...

In Java, how do I convert a byte array to a string of hex digits while keeping leading zeros?

I'm working with some example java code for making md5 hashes. One part converts the results from bytes to a string of hex digits: byte messageDigest[] = algorithm.digest(); StringBuffer hexString = new StringBuffer(); for (int i=0;i<messageDigest.length;i++) { hexString.append(Integer.toHexString(0xFF & messageDigest[i])); ...

Working with hex numbers in MySQL

I have a stored procedure that needs to convert hexadecimal numbers to their decimal equivalent. I've read the documentation for the UNHEX() function, but it is returning a binary value. What I'm wanting to do is something like this: CREATE PROCEDURE foo( hex_val VARCHAR(10) ) BEGIN DECLARE dec_val INTEGER; SET dec_val = UNHE...

I need to do a fill pattern in Intel hex file. My question is how would I do a fill pattern of an arbitrary size?

I have been trying to do a fill using the open source Srecord Program. The thing is I need to do a fill that is 0xC2AF00. It appears the program can only do fills that are a byte long (ex: 0xff).If this is not possible with the Srecord program, then how would I go about writing my own algorithm to do what I want. I am not quite sure ho...

Best way to decode hex sequence of unicode characters to string

Hello, What is the most code free way to decode a string: \xD0\xAD\xD0\xBB\xD0\xB5\xD0\xBA\xD1\x82\xD1\x80\xD0\xBE\xD0\xBD\xD0\xBD\xD0\xB0\xD1\x8F to human string in C#? This hex string contains some unicode symbols. I know about System.Convert.ToByte(string, fromBase); But I was wondering if there are some built-in helpers tha...

Convert decimal to hexadecimal in UNIX shell script

In a UNIX shell script, what can I use to convert decimal numbers into hexadecimal? I thought od would do the trick, but it's not realizing I'm feeding it ASCII representations of numbers. printf? Gross! Using it for now, but what else is available? :) ...

AJAX Asp.net AutoCompleteExtender interpreting string 0010 as octal

I'm using the MS AJAX AutoCompleteExtender on a textbox. It's working fine, except when the web service returns strings like "0010" -- in which case, it displays "8". I eventually realised it was interpreting the string "0010" as an octal number (and then proved the point by adding strings like "0100" and "0x10".) How can I prevent thi...

How would you reverse engineer this?

I've got some code that was at the bottom of a php file that is in javascript. It goes through lots of weird contortions like converting hex to ascii then doing regex replacements, executing code and so on... Is there any way to find out what it's executing before it actually does it? The code is here: http://pastebin.ca/1303597 G-M...

How to create python bytes object from long hex string?

I have a long sequence of hex digits in a string, such as 000000000000484240FA063DE5D0B744ADBED63A81FAEA390000C8428640A43D5005BD44 only much longer, several kilobytes. Is there a builtin way to convert this to a bytes object in python 2.6/3? ...

Why use hex values instead of normal base 10 numbers?

I was looking over this code to calculate math.sqrt in Java. I was just wondering why they used hex values in some of the loops and as normal values for variables. What benefits are there to use hex? Thanks for your help. ...

c++ cout hex values?

I want to do: int a = 255; cout << a; and have it show FF in the output, how would i do this? ...

How can i convert hex numbers to binary in c++?

I am taking a beginning c++ class, and would like to convert letters between hex representations and binary. I can manage to print out the hex numbers using: for(char c = 'a'; c <= 'z'; c++){ cout << hex << (int)c; } But I can't do the same for binary. There is no std::bin that I can use to convert the decimal numbers to binary. H...

Two encodings used in RTF string won't display correct in RichTextBox?

I am trying to parse some RTF, that i get back from the server. For most text i get back this works fine (and using a RichTextBox control will do the job), however some of the RTF seems to contain an additional "encoding" and some of the characters get corrupted. The original string is as follows (and contains some of the characters u...

[C/C++] double to hex string & hex string to double

Hi, What I'm trying to do is to convert a double to hex string and then back to double. The following code does conversion double-to-hex string. char * double2HexString(double a) { char *buf = new char[17]; // double is 8-byte long, so we have 2*8 + terminating \0 char *d2c; d2c = (char *) &a; char *n = buf; int i; f...