Solved

hex to int

Posted on 2000-03-09
1
752 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
[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
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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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
windows 10 how make picture as desktop background 2 73
Not needed 13 134
I could not set window to top 4 63
Adjust the codes 3 63
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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.

751 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