Solved

hex to int

Posted on 2000-03-09
1
709 Views
Last Modified: 2013-11-20
Hi, community!

When I have got a WORD variable that contains a hex-value and I need this value as int to calculate with it, how do I convert it?
And how do I convert any numeric type variable into CString in order to control the value in a MessageBox?
0
Comment
Question by:BoogieBoy
1 Comment
 
LVL 31

Accepted Solution

by:
Zoppo earned 5 total points
ID: 2600198
Hi BoogieBoy,

numeric variables do not differ between a hex or a decimal or something. Hex is just how an app shows a value. I.e.

ASSERT( 0x0f == 15 ); // will always be true

to convert a numeric value to a CString you can use CString::Format(), i.e.

....
int x = 123456789;
double f = 12345.6789;
CString t;
t.Format( "x = %d (hex:0x%08X), f = %f (%e).", x, x, f, f );

sets t to:
"x = 123456789 (hex:0x075BCD15), f = 12345.678900 (1.234568e+004)"

hope that helps,

ZOPPO
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

919 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now