Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Hexadecimal data

Posted on 2000-04-06
2
Medium Priority
?
459 Views
Last Modified: 2008-03-10
Hallo,

I need a function that makes the convertion hexadecimal<-->decimal.
The hexadecimal value is a CString, and the decimal value is an integer.

Something like:

int hexa2dec (CString input);

CString dec2hexa (int input);
0
Comment
Question by:fcogilgo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 10

Accepted Solution

by:
RONSLOW earned 400 total points
ID: 2689875
dec2hexa is just the standard itoa function, with a radix of 16

hexa2deb is just strtol with a base of 16.
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 2689889
int hexa2dec (CString input) {
  char* dummy;
  return strtol(input,&dummy,16);
}
CString dec2hexa (int input) {
  CString string;
  itoa(input,string.GetBuffer(64),16);
  string.ReleaseBuffer();
  return string;
}
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question