[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
Solved

Convert Binary from Malloced Buffer to a float

Posted on 2004-09-16
Medium Priority
272 Views
I need to convert binary numbers i am getting from malloced data to float so i can divide it, then compare it.
0
Question by:whinson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 4
• 2

LVL 9

Expert Comment

ID: 12081228
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

Author Comment

ID: 12081243
The type is float.  It has multiple items.
0

LVL 9

Accepted Solution

ankuratvb earned 1500 total points
ID: 12081322
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

Author Comment

ID: 12081334
I figured it out by myself thanks.  I will give you the points.
0

LVL 9

Expert Comment

ID: 12081342
0

LVL 9

Expert Comment

ID: 12081355
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

Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
Suggested Courses
Course of the Month14 days, 16 hours left to enroll