Solved

hex to int

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

Accepted Solution

by:
Zoppo earned 5 total points
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
List out all word 7 219
sum13 challenge 24 77
canBalance challenge 34 65
noX challenge 17 75
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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. …
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.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

772 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

11 Experts available now in Live!

Get 1:1 Help Now