Mail Archives: djgpp/1999/07/27/16:40:25
From: | "Campbell, Rolf [SKY:1U32:EXCH]" <cp1v45 AT americasm01 DOT nt DOT com>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: Forming a float from 4 seperate bytes
|
Date: | Tue, 27 Jul 1999 16:12:35 -0400
|
Organization: | Nortel Networks
|
Lines: | 22
|
Message-ID: | <379E12B3.22F6FF1F@americasm01.nt.com>
|
References: | <7nku8s$hkl$1 AT nnrp1 DOT deja DOT com>
|
NNTP-Posting-Host: | bmerhc00.ca.nortel.com
|
Mime-Version: | 1.0
|
X-Mailer: | Mozilla 4.7 [en] (X11; I; HP-UX B.10.20 9000/712)
|
X-Accept-Language: | en
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
jsc AT lds DOT co DOT uk wrote:
> However I want
> to unload the file to a buffer and then start parsing. I've done the reading
> into the buffer, but now I don't know how to reform my float from the data, I
> tried taking the 4 values and &-ing them together, but that doesn't work as
> the final value I'm after is a float and I get an operand error. Any ideas on
> how to take 4 integers and form the float? I'm surre it's easy but I can't
> get it to work. Thanks Chris jsc AT lds DOT co DOT uk
Once you have it in the buffer, and you find the beginning of the float:
char* buffer; //must malloc after.
if the float is at buffer[100], then use
float val = *(float*)(buffer+100);
--
-Rolf Campbell (39)3-6318
- Raw text -