Solved

Convert Binary from Malloced Buffer to a float

Posted on 2004-09-16
6
260 Views
Last Modified: 2010-04-15
I need to convert binary numbers i am getting from malloced data to float so i can divide it, then compare it.
0
Comment
Question by:whinson
  • 4
  • 2
6 Comments
 
LVL 9

Expert Comment

by:ankuratvb
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

by:whinson
ID: 12081243
The type is float.  It has multiple items.  
0
 
LVL 9

Accepted Solution

by:
ankuratvb earned 500 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
Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

 

Author Comment

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

Expert Comment

by:ankuratvb
ID: 12081342
0
 
LVL 9

Expert Comment

by:ankuratvb
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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
libcurl - taking long time on curl_easy_perform 11 437
C++ vs C compilers 13 160
C hashtable library 3 100
c++ getting the first 10 characters of a char* string 11 99
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
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 opening and reading files in the C programming language.

828 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