hexadecimal

hex dump of file in bash

How do I create a UNMODIFIED hex dump of a binary file in linux with bash? The od and hexdump commands both insert spaces in the dump, I DON'T WANT THIS, I need something that will simply write a long string with all the hex characters without inserting spaces or newlines in the output. How do I do this in bash? ...

What's the most effective way to interpolate between two colors? (pseudocode and bitwise ops expected)

Making a Blackberry app, want a Gradient class. What's the most effective way (as in, speed and battery life) to interpolate two colors? Please be specific. // Java, of course int c1 = 0xFFAA0055 // color 1, ARGB int c2 = 0xFF00CCFF // color 2, ARGB float st = 0 // the current step in the interpolation, between 0 and 1 He...

setBit java method using bit shifting and hexadecimal code - question

I am having trouble understanding what is happening in the two lines with the 0xFF7F and the one below it. There is a link here that explains it to some degree. http://www.herongyang.com/java/Bit-String-Set-Bit-to-Byte-Array.html I don't know if 0xFF7F>>posBit) & oldByte) & 0x00FF are supposed to be 3 values 'AND'ed together or how this...

Why are Hexadecimal Prefixed as 0x?

Why are Hexadecimal Prefixed as 0x and not anything else? I understand the usage of prefix but I dont understand the significance of 0x. ...

Converting binary to hexadecimal??

Hey guys, Just wondering on how I would go about converting binary to hexadecimal?? Would I first have to convert the binary to decimal and then to hexadecimal?? For example, 101101001.101110101010011 How would I go about converting a complex binary such as the above to hexadecimal? Thanks in advance ...

Improving method to read signed 8-bit integers from hexadecimal.

Scenario: I have a string of hexadecimal characters which encode 8-bit signed integers. Each two characters represent a byte which employ the leftmost (MSB) bit as the sign (rather than two's complement). I am converting these to signed ints within a loop and wondered if there's a better way to do it. There are too many conversions and ...

How do I replace characters not in range [0x5E10, 0x7F35] with '*' in PHP?

I'm not familiar with the how regular expressions treat hexadecimal, anyone knows? ...

C - Convert long int to signed hex string

MASSIVE EDIT: I have a long int variable that I need to convert to a signed 24bit hexadecimal string without the "0x" at the start. The string must be 6 characters followed by a string terminator '\0', so leading zeros need to be added. Examples: [-1 -> FFFFFF] --- [1 -> 000001] --- [71 -> 000047] Answer This seems to do the trick: ...

Trying to parse a file that looks partically hex encoded

Hello, I'm trying to parse a file that looks sort of hex encoded but mostly not. I contacted support for the vendor who created the file and they said that they it can be parsed using "an 0x116 offset" What is a 0x116 offset? It took me 2 weeks to get an answer from the vendor on my first question, so I wanted to see if someone here ...

Convert hexadecimal notation into latitudinal hours and minutes

Given: 0x12E7 represents 48°39' 0x3026 represents 123°26' What is the most efficient way to convert the representation of those latitudes into two variables: hours minutes Where the first example would be: hours = 48 minutes = 39 And the second example: hours = 123 minutes = 26 Edit Latitude is an int. ...

Java Regex for matching hexadecimal numbers in a file

So I'm reading in a file (like java program < trace.dat) which looks something like this: 58 68 58 68 40 c 40 48 FA If I'm lucky but more often it has several whitespace characters before and after each line. These are hexadecimal addresses that I'm parsing and I basically need to make sure that I can get the line using a scanner, bu...

Signed Hexidecimal value range

Say I had a 6 digit hexadecimal signed in two's complement. What would be its range? -(16 ^ 5) < x < (16 ^ 5) Correct? ...

[C] Signed Hexadecimal string to long int function

I need a function to convert a 32bit or 24bit signed (in two's complement) hexadecimal string into a long int. Needs to work on both 32bit and 64bit machines (regardless of the size of long int) and work regardless of whether the machine is a two's complement machine or not. SOLUTION: long int hex2li (char hexStr[], int signedHex) { ...

Passing huge amounts of data as an hexadecimal (0x123AB...) parameter of a clr stored procedure in sql server

I post this question has followup of This question, since the thread is not recieving more answers. I'm trying to understand if it is possible to pass as a parameter of a CLR stored procedure a large amount of data as "0x5352532F...". This is to avoid to send the data directly to the CLR stored procedure, instead of sending ti to a tem...

Looking for advice on how to do some bit-twiddling

Suppose I have the array int a[] = new int[] { 0xBCDA, 0xABFE, 0xBCAD, 0xEFCA, 0xFFCA } I know that there is always some hexadecimal number which occurs in all number or in this case A is repeated in the array everywhere so my aim is print only the repeated number and other numbers should be zero, so my new array should be like thi...

Delphi: how to efficently read a big binary file, converting it to hexadecimal for passing it as a varbinary(max) parameter?

I need to convert a binary file (a zip file) into hexadecimal representation, to then send it to sql-server as a varbinary(max) function parameter. A full example (using a very small file!) is: 1) my file contains the following bits 0000111100001111 2) I need a procedure to QUICKLY convert it to 0F0F 3) I will call a sql server funct...

Binary to Ascii and back again

I'm trying to interface with a hardware device via the serial port. When I use software like Portmon to see the messages they look like this: 42 21 21 21 21 41 45 21 26 21 29 21 26 59 5F 41 30 21 2B 21 27 42 21 21 21 21 41 47 21 27 21 28 21 27 59 5D 41 32 21 2A 21 28 When I run them thru a hex to ascii converter the commands don't m...

Convert Hexadecimal String to Data

Hi Stack Overflow, I have found a whole lot of different solutions to this problem, but not all of them work, and a lot of them seem somewhat hacky and inefficient. Basically I have a string of hexadecimal data (i.e. "55 AA 41 2A 00 94 55 AA BB BB 00 FF") which I would like to convert to raw data. What is the best way to do this? UPDAT...

How do I convert a string the looks like a hex number to an actual hex number in php?

Hey everyone, I have a string that looks like this "7a" and I want to convert it to the hex number 7A. I have tried using pack and unpack but that is giving me the hex representation for each individual character. I'm out of ideas and don't know where to go from here. Thanks for the help! ...

Trying to figure out how to check a checksum

I'm trying to figure out how to check a checksum. My message looks like this: 38 0A 01 12 78 96 FE 00 F0 FB D0 FE F6 F6 being the checksum. I convert the preceding 12 sets in to binary and then add them together. Then attempt a bitwise operation to apply the 2s complement. I get a value of -1562, but I can't convert it back to hex to ...