Can anyone give me an idea how to convert an int or decimal number into hexadecimal? I know how to do it for binary by dividing by 2 and using the modulus % operator, but how do you take into account a b c d e f if the integer is greater than 9? any ideas would greatly be appreciated.

## Recommended Answers

Jump to Post>but how do you accomdate for the letters a-f if the digits are greater than 9?

Use a string:`static const string hex ( "0123456789ABCDEF" );`

This is a simple problem once you figure it out. The function shouldn't need to be more than 4 or 5 …

## All 7 Replies

Dave Sinkula
2,398
long time no c
Team Colleague

cblue
0
Newbie Poster

Narue
5,707
Bad Cop
Team Colleague

cblue
0
Newbie Poster

Narue
5,707
Bad Cop
Team Colleague

cblue
0
Newbie Poster

Narue
5,707
Bad Cop
Team Colleague

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.