473,394 Members | 1,956 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Integer to Hex

Hi,
I want to convert an integer (actuallu the ascii value of a character) to its equivalent Hex value. Can someone suggest, which is the easiest way to do it.

Thanks in advance,
Al.
Nov 16 '05 #1
5 23572
String.Format( "{0:X2}", intValue)

--
Floyd Burger

"Al Sav" <Al Sa*@discussions.microsoft.com> wrote in message
news:3B**********************************@microsof t.com...
Hi,
I want to convert an integer (actuallu the ascii value of a character) to its equivalent Hex value. Can someone suggest, which is the easiest way to
do it.
Thanks in advance,
Al.

Nov 16 '05 #2
Al,

Try something like

string hexString = String.Format("{0:x2}", intVal);

Paul Qualls

"Al Sav" <Al Sa*@discussions.microsoft.com> wrote in message
news:3B**********************************@microsof t.com...
Hi,
I want to convert an integer (actuallu the ascii value of a character) to its equivalent Hex value. Can someone suggest, which is the easiest way to
do it.
Thanks in advance,
Al.

Nov 16 '05 #3
for (int i = 0; i < 16; i++)
Console.WriteLine(Convert.ToString(i,16));

"Al Sav" <Al Sa*@discussions.microsoft.com> wrote in message
news:3B**********************************@microsof t.com...
Hi,
I want to convert an integer (actuallu the ascii value of a character) to its equivalent Hex value. Can someone suggest, which is the easiest way to
do it.
Thanks in advance,
Al.

Nov 16 '05 #4
string.Format("0x{0:x}", i)
??


"Al Sav" <Al Sa*@discussions.microsoft.com> wrote in message
news:3B**********************************@microsof t.com...
Hi,
I want to convert an integer (actuallu the ascii value of a character) to its equivalent Hex value. Can someone suggest, which is the easiest way to
do it.
Thanks in advance,
Al.

Nov 16 '05 #5
Thanks for all the response and different methods.

I ended up using this:
((int) c).ToString("x")

c is a char.

I am surprised to see so many different solutions, whereas I was trying so hard to find a solution.
Alwin S.
"Beeeeeves" wrote:
string.Format("0x{0:x}", i)
??


"Al Sav" <Al Sa*@discussions.microsoft.com> wrote in message
news:3B**********************************@microsof t.com...
Hi,
I want to convert an integer (actuallu the ascii value of a character) to

its equivalent Hex value. Can someone suggest, which is the easiest way to
do it.

Thanks in advance,
Al.


Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Tony Johansson | last post by:
Hello! I have some problem with STL function remove I have two classes called Handle which is a template class and Integer which is not a template class. The Integer class is just a wrapper...
11
by: nephish | last post by:
Hello there, i need a way to check to see if a certain value can be an integer. I have looked at is int(), but what is comming out is a string that may be an integer. i mean, it will be formatted...
21
by: Frederick Gotham | last post by:
I set about trying to find a portable way to set the value of UCHAR_MAX. At first, I thought the following would work: #define UCHAR_MAX ~( (unsigned char)0 ) However, it didn't work for me....
8
by: Candace | last post by:
I am using the following code to pick off each digit of a number, from right to left. The number I am working with is 84357. So for the first iteration it should return the number 7 and for the...
1
by: charles_gero | last post by:
Hi all, I had a question about the topics in the subject and posted to comp.std.c, but feel it may also be appropriate here. Please excuse this crosspost if it is in bad form. I have a...
7
by: laura | last post by:
Hi, I have a variable of type double. I need to know if there is an integer number store there. How can I test that ? I also have a default precision for doing this operation. Many thanks,...
9
by: jacob navia | last post by:
Hi I am incorporating 128 Bit integer code into lcc-win and it would be nice to have some code to test this feature. Has anyone here code that uses 128 bit integers? Thanks in advance ...
12
by: lithiumcat | last post by:
Hi, I bothered you a while back about storing integer values in void*. Now in a completely unrelated context, I'm trying to store pointer values in an integer type. So the basic question is,...
14
by: Default User | last post by:
Hi, If I have three 64 bit integers and I want to do this operation on them: x*y/z Lets say that what we are multiplying by (y) is offset by what we are dividing by (z) so that the final...
9
by: tsuyois | last post by:
Hi, I just signed in to this excellent network. I hope I could get some answers to many questions I have in writing C compilers. My first question is: Is "integer demotion" required in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.