Link to home
Start Free TrialLog in
Avatar of whinson
whinson

asked on

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.
Avatar of ankuratvb
ankuratvb
Flag of United States of America image

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:
https://www.experts-exchange.com/questions/20839804/float-from-raw-binary-array.html

Avatar of whinson
whinson

ASKER

The type is float.  It has multiple items.  
ASKER CERTIFIED SOLUTION
Avatar of ankuratvb
ankuratvb
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of whinson

ASKER

I figured it out by myself thanks.  I will give you the points.
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.