Questions tagged [hex]

Hexadecimal (also base 16, or hex) is the base-16 positional numeral system, using the 16 symbols 0–9 and A‒F.

Hexadecimal (also base 16, or hex) is a numeral system with a base of 16. It uses sixteen distinct symbols, most often the symbols 0–9 to represent values zero to nine, and A, B, C, D, E, F (or alternatively a–f) to represent values ten to fifteen.

Each hexadecimal digit represents four binary digits (bits), and the primary use of hexadecimal notation is a human-friendly representation of binary-coded values in computing and digital electronics. More information may be found here.

Other numeral systems:

9640 questions
366
votes
14 answers

How to get a Color from hexadecimal Color String

I'd like to use a color from an hexa string such as "#FFFF0000" to (say) change the background color of a Layout. Color.HSVToColor looks like a winner but it takes a float[] as a parameter. Am I any close to the solution at all?
Johann
  • 12,158
  • 11
  • 62
  • 89
340
votes
4 answers

How can I convert a hex string to a byte array?

Can we convert a hex string to a byte array using a built-in function in C# or do I have to make a custom method for this?
Blankman
  • 259,732
  • 324
  • 769
  • 1,199
296
votes
14 answers

How to convert an int to a hex string?

I want to take an integer (that will be <= 255), to a hex string representation e.g.: I want to pass in 65 and get out '\x41', or 255 and get '\xff'. I've tried doing this with the struct.pack('c',65), but that chokes on anything above 9 since it…
pynoob
  • 2,963
  • 2
  • 16
  • 4
261
votes
5 answers

printf() formatting for hexadecimal

Why, when printing a number in hexadecimal as an 8 digit number with leading zeros, does %#08X not display the same result as 0x%08X? When I try to use the former, the 08 formatting flag is removed, and it doesn't work with just 8.
wsmccusker
  • 2,631
  • 2
  • 14
  • 8
240
votes
13 answers

How to convert a color integer to a hex String in Android?

I have an integer that was generated from an android.graphics.Color. It has a value of -16776961. How do I convert it into a hex string with the format #RRGGBB? Simply put: I would like to output #0000FF from -16776961. Note: I don't want the output…
Bosah Chude
  • 3,670
  • 2
  • 22
  • 22
237
votes
19 answers

Create a hexadecimal colour based on a string with JavaScript

I want to create a function that will accept any old string (will usually be a single word) and from that somehow generate a hexadecimal value between #000000 and #FFFFFF, so I can use it as a colour for a HTML element. Maybe even a shorthand hex…
Darragh Enright
  • 13,676
  • 7
  • 41
  • 48
232
votes
10 answers

Understanding colors on Android (six characters)

I am trying to understand how colors work in Android. I have this color set as the background of my LinearLayout, and I get a background gray with some transparency:
Thiago
  • 5,152
  • 11
  • 35
  • 44
228
votes
9 answers

How to create a hex dump of file containing only the hex characters without spaces in bash?

How do I create an unmodified hex dump of a binary file in Linux using bash? The od and hexdump commands both insert spaces in the dump and this is not ideal. Is there a way to simply write a long string with all the hex characters, minus spaces or…
David Raswik
  • 2,281
  • 2
  • 14
  • 3
217
votes
5 answers

Converting an integer to a hexadecimal string in Ruby

Is there a built in way to convert an integer in Ruby into its hexadecimal equivalent? Something like the opposite of String#to_i: "0A".to_i(16) #=>10 Like perhaps: "0A".hex #=>10 I know how to roll my own, but it's probably more efficient to use…
Matt Haughton
  • 2,919
  • 3
  • 24
  • 30
206
votes
25 answers

How to get hex color value rather than RGB value?

Using the following jQuery will get the RGB value of an element's background color: $('#selector').css('backgroundColor'); Is there a way to get the hex value rather than the RGB?
jason
205
votes
28 answers

Integer to hex string in C++

How do I convert an integer to a hex string in C++? I can find some ways to do it, but they mostly seem targeted towards C. It doesn't seem there's a native way to do it in C++. It is a pretty simple problem though; I've got an int which I'd like to…
kryptobs2000
  • 3,289
  • 3
  • 27
  • 30
201
votes
8 answers

Transparent ARGB hex value

The colors in this table is all not transparent. I guess the value for the A is set to FF. What is the code for transparency? For example this color FFF0F8FF (AliceBlue), to a transparent code such as ??F0F8FF ?
user3332579
  • 3,111
  • 3
  • 17
  • 21
197
votes
6 answers

What's a good hex editor/viewer for the Mac?

What's a good hex editor/viewer for the Mac? I've used xxd for viewing hexdumps, and I think it can be used in reverse to make edits. But what I really want is a real hex editor.
Mike Akers
  • 12,039
  • 14
  • 58
  • 71
195
votes
9 answers

Convert from ASCII string encoded in Hex to plain ASCII?

How can I convert from hex to plain ASCII in Python? Note that, for example, I want to convert "0x7061756c" to "paul".
Paul Reiners
  • 8,576
  • 33
  • 117
  • 202
193
votes
10 answers

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?
user34537