Click here to Skip to main content
Licence 
First Posted 4 Feb 2003
Views 43,607
Bookmarked 14 times

How to convert HUGE numbers to Hex string and back

By | 4 Feb 2003 | Article
How to convert big numbers to ready-to-display hex numbers.

Introduction

During my work with systems that use a huge memory address range, I had to display memory addresses in hex format that were very hard to convert into string. The usual %x flag will only work with up to 16 bit hex values and any code example you will see on the Internet is limited to even less than that.

So, I sat down and wrote 2 generic functions you can use:

  • hex_string_to_long - This one will take a hex string such as "10FBBC45" and convert it to a very long integer.
  • convert_long_to_hex - Will ask you for the number you want to convert and for a string reference that it will return the answer into.

Don't forget to include the math.h library in your code and you should be all set. Just copy and paste the functions to your code.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Shay Harel

Software Developer (Senior)
EMC
United States United States

Member

12 Years experience in: C , C++ , MFC.
Embedded programming.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralSorry to tell you, but... PinmemberAndreas Saurwein6:19 5 Feb '03  
GeneralRe: Sorry to tell you, but... PinmemberJörgen Sigvardsson9:48 5 Feb '03  
GeneralRe: Sorry to tell you, but... PinmemberAndreas Saurwein5:14 6 Feb '03  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web03 | 2.5.120517.1 | Last Updated 5 Feb 2003
Article Copyright 2003 by Shay Harel
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid