Solved

double to hexadecimal

Posted on 2009-05-15
9
446 Views
Last Modified: 2012-05-07
Hi,

I want to know C functions which perform "double to Hexadecimal" and "Hexadecimal to double"
Can you please help me how to write code of above?

Thanks...
0
Comment
Question by:palhade
9 Comments
 
LVL 39

Accepted Solution

by:
abel earned 500 total points
Comment Utility
0
 
LVL 40

Expert Comment

by:evilrix
Comment Utility
>> I want to know C functions which perform "double to Hexadecimal" and "Hexadecimal to double"
Double is a c/c++ type whereas hexadecimal is a number base (base 16). Therefore, can you please clarify what you mean by this since the question doesn't contain enough information to provide an answer. Are you saying you want to convert a double to a string representation in hexadecimal?
0
 
LVL 53

Expert Comment

by:Infinity08
Comment Utility
IN C99, you can use the %a or %A format with the printf family to print a floating point value in hexadecimal.

The standard strtod function also supports hexadecimal floating point values (in C99).
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:palhade
Comment Utility
convert a double to a string representation in hexadecimal?
I am using VC++ Express edition
0
 
LVL 39

Expert Comment

by:abel
Comment Utility
inside memory, the double takes 8 bytes. You can place them into hexadecimal, which is what I showed you. If that is not what you want, can you give an example of what goes into your function and what you expect it to go out?

btw: have you tried my suggestion and if so, what are your results and/or follow-up questions?
0
 
LVL 53

Expert Comment

by:Infinity08
Comment Utility
>> convert a double to a string representation in hexadecimal?

See my earlier post. For C99, you can use the %a or %A format with sprintf. Otherwise, you can use a custom solution ...
0
 
LVL 39

Expert Comment

by:abel
Comment Utility
Thanks for grading me, but you got many answers and follow-ups. Lower-grading is something you should use for those cases where you haven't received a complete answer, tried to get more info, but didn't get it. You have not clarified your requirements, got many suggestions but did not follow-up. Sorry, but that's not the way things work over here. Consider splitting points and the 10pts must principle in the EE FAQ.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…

763 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

10 Experts available now in Live!

Get 1:1 Help Now