how to check whether given numbe ris hex or not


 
Thread Tools Search this Thread
Top Forums Programming how to check whether given numbe ris hex or not
# 1  
Old 10-06-2008
how to check whether given numbe ris hex or not

helo I have particular number

lets say 0x56

now thropugh c program how to check this number is hex or not

Regards,
Amit
# 2  
Old 10-06-2008
All numbers are (normally) represented internally as binary objects. Do you mean you have a particular string that you want to parse? And you want to know if this string is hex? Or do you just want to parse any string -- decimal or hex -- into the proper internal representation?
# 3  
Old 10-06-2008
Certain conventions are used when dealing with numbers in different bases. Hex digits are prefixed with 0x or 0X; octals have a leading zero; and decimals are written as is...
Code:
int dec, oct, hx;
oct = 056; /* octal 56 */ 
hx = 0x56; /* hex 56 */
dec = 56; /* decimal 56 */

Is that it or are you looking to parse a string of characters into hex / decimal digits? The requirements are not clear from your post.
# 4  
Old 10-06-2008
Or maybe you are simply looking for isxdigit()
# 5  
Old 10-07-2008
prefixed with 0x and every digit must be in between 0-9 and a-f.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to replace with "sed" some hex values by other hex values?

Assume I have a file \usr\home\\somedir\myfile123.txt and I want to replace all occurencies of the two (concatenated) hex values x'AD' x'A0' bytwo other (concatenated) hex values x'20' x'6E' How can I achieve this with the gnu sed tool? Additional question: Is there a way to let sed show... (1 Reply)
Discussion started by: pstein
1 Replies

2. Programming

What is the difference between ios::hex and std::hex?

Hi, Is there really a difference between these two, std::hex and ios::hex?? I stumbled upon reading a line, "std::ios::hex is a bitmask (8 on gcc) and works with setf(). std::hex is the operator". Is this true? Thanks (0 Replies)
Discussion started by: royalibrahim
0 Replies

3. UNIX for Advanced & Expert Users

Linux RIS server installation

Hi, I'm Samir and I'm new here, actually I'm facing a problem, I'm trying to configure a Linux RIS (Remote Installation Server) to drive windows installation from a Linux RHEL5 I got a guide to do that and followed precisely, I am getting this error message in the client side Setup cannot... (2 Replies)
Discussion started by: samir82show
2 Replies

4. Programming

ascii to hex

Hello guys, i want to convert a text file to hex and have written this code : int main(int argc, char **argv) { ifstream file; string fileName = "CODEZ"; file.open(fileName.c_str()); // oeffen im Text-Modus if(file) {... (5 Replies)
Discussion started by: Kingbruce
5 Replies

5. Programming

After converting the hexstr to Hex and storing the Hex in a char*

Hi All, My main intension of is to convert the Hexstring stored in a char* into hex and then prefixing it with "0x" and suffix it with ',' This has to be done for all the hexstring char* is NULL. Store the result prefixed with "0x" and suffixed with ',' in another char* and pass it to... (1 Reply)
Discussion started by: rvan
1 Replies

6. Shell Programming and Scripting

hex to decimal

hi all, echo "ibase=16;obase=10;11" | bc shouldn't i get 17? i am getting 11 i am trying to convert 11 (hex) to decimal stuck! JAK (4 Replies)
Discussion started by: jakSun8
4 Replies

7. UNIX for Dummies Questions & Answers

Hex editing

Hi, I am new to UNIX. I have a text file where each line ends on the hexadecimal character "0A". In the file there are some records that contain the Hex characters "0D0A" which I need to replace by Hex "20". Is there a simple way to do this? Regards, Swanie (3 Replies)
Discussion started by: Swanie
3 Replies

8. Shell Programming and Scripting

Looking for a hex character?

Hi guys , i would want to count the concurrences of the 0A hex char in a text file , then if no matches i need to add a 0A at the end of the line. Any ideas? thx.Regards (1 Reply)
Discussion started by: Klashxx
1 Replies

9. UNIX for Dummies Questions & Answers

Calculation - Result not accurate if numbe too big

Dear all, Below is my script, totalCount=57006427 totalSummCount=1207590 let percentageSumTmp1=${totalCount}-${totalSummCount} let percentageSumTmp2=${percentageSumTmp1}*100 The expected result for percentageSumTmp2 should be (5579883700), but when I execute the script in unix env i... (3 Replies)
Discussion started by: epall
3 Replies

10. UNIX for Dummies Questions & Answers

Ascii To Hex

How will I display on screen a UNIX ascii file with its HEX equivalent. I want to check whether 0D 0A is coming at the end of the file which I am generating from UNIX. (1 Reply)
Discussion started by: augustinep
1 Replies
Login or Register to Ask a Question