Solved

hex to int

Posted on 2000-03-09
1
743 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Decoding 32 bit binary streams 6 53
C++ BOOL WINAPI ReadFile fails on windows 10 when reading from USB cable 9 509
zeroFront challenge 7 121
Detect file exist or not 3 198
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

679 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