• C

Convert Binary from Malloced Buffer to a float

I need to convert binary numbers i am getting from malloced data to float so i can divide it, then compare it.
whinsonAsked:
Who is Participating?
 
ankuratvbConnect With a Mentor Commented:
Ok.So you have the binary numbers stored as floats.Right?

Something like:

float *buf;
buf=(float*)malloc(20*sizeof(float));
buf[0]=11001.11;
buf[1]=10010.11;
.
.
//And you need the decimal values of these individual elements,right?
free(buf);
0
 
ankuratvbCommented:
What is the problem?

What is the type of the malloced buffer,is it char?

Is it something like:

char *buf;
buf=(char*)malloc(20*sizeof(char));
strcpy(buf,"1100110");
//Now you need the decimal value of 1100110 in a float.Is this what you need?
free(buf);

You need to retrieve only 1 number from the malloced data or more than one?

See this,it might help:
http://www.experts-exchange.com/Programming/Programming_Languages/C/Q_20839804.html

0
 
whinsonAuthor Commented:
The type is float.  It has multiple items.  
0
Protect Your Employees from Wi-Fi Threats

As Wi-Fi growth and popularity continues to climb, not everyone understands the risks that come with connecting to public Wi-Fi or even offering Wi-Fi to employees, visitors and guests. Download the resource kit to make sure your safe wherever business takes you!

 
whinsonAuthor Commented:
I figured it out by myself thanks.  I will give you the points.
0
 
ankuratvbCommented:
0
 
ankuratvbCommented:
Nice to know you figured it out yourself. :~)

You also have the option of getting your points refunded by posting your solution and asking for a refund in Community Support.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.