delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/03/23/17:50:47

Message-ID: <38DA98FF.249D077E@unb.ca>
From: Endlisnis <s257m AT unb DOT ca>
X-Mailer: Mozilla 4.7 [en] (Win98; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Binary to double in C
References: <bKvC4.964$ED DOT 25221 AT news2-win DOT server DOT ntlworld DOT com>
Lines: 24
Date: Thu, 23 Mar 2000 22:21:58 GMT
NNTP-Posting-Host: 24.114.6.233
X-Complaints-To: abuse AT home DOT net
X-Trace: news1.rdc1.on.wave.home.com 953850118 24.114.6.233 (Thu, 23 Mar 2000 14:21:58 PST)
NNTP-Posting-Date: Thu, 23 Mar 2000 14:21:58 PST
Organization: @Home Network Canada
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Ben Alford wrote:

> I am using fread to read in a binary line as follows:
> char Data[9];
>     fread(Data, sizeof(double),1,Output);
> I want to take the binary string in Data and get the value of it as a
> double.

Well, you could:
double Data;
fread((char*)&Data, sizeof(double), 1, Output);

Or you could:
char Data[9];
    fread(Data, sizeof(double),1,Output);
double Double = *(double*)Data;

--
     (\/) Endlisnis (\/)
          s257m AT unb DOT ca
          Endlisnis AT HotMail DOT com
          ICQ: 32959047


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019