Article View: microsoft.public.vc.language
Article #99Re: IEEE conversion: bytes into floating point number...
From: Eric Meijer
Date: Mon, 14 Jul 1997 00:00
Date: Mon, 14 Jul 1997 00:00
34 lines
1669 bytes
1669 bytes
dave (drs@cs.wisc.edu) wrote:
: [G++ 2.7.2 or VC++ 4.0]
: Greetings,
: I need to convert a data string like this:
: "111 134 27 240 249 33 9 64" (dec.)
: "6F 86 1B F0 F9 21 09 40" (hex)
[... into a double precisionnumber ... ]
What about
------------------------------------------------------------------------
#include <iostream.h"
int main() {
signed char bytes={111,134,27,240,249,33,9,64};
double* d = (double *)bytes;
cout << bytes << endl;
}
------------------------------------------------------------------------
If I compile this with g++ 2.7.2, It prints 3.14159. That looks like a
non random number to me. I wouldn't claim this is any portable, but it
does seem to work.
Eric Meijer
--
E.L. Meijer
Eindhoven Univ. of Technology
Lab. for Catalysis and Inorg. Chem.
Technical Details
Message-ID:
<5qcobl$c5q@tuegate.tue.nl>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<33C83D2D.4528@cs.wisc.edu>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1014db,c41b066001ba50e9 X-Google-Attributes: gid1014db,public X-Google-Thread: 10ba33,c41b066001ba50e9 X-Google-Attributes: gid10ba33,public X-Google-Thread: 109fba,c41b066001ba50e9 X-Google-Attributes: gid109fba,public X-Google-Thread: f7a51,c41b066001ba50e9 X-Google-Attributes: gidf7a51,public From: tgakem@sg14.chem.tue.nl (Eric Meijer) Subject: Re: IEEE conversion: bytes into floating point number... Date: 1997/07/14 Message-ID: <5qcobl$c5q@tuegate.tue.nl> X-Deja-AN: 256800562 References: <33C83D2D.4528@cs.wisc.edu> Followup-To: microsoft.public.vc.language,comp.lang.c,comp.lang.c++,gnu.g++.help Organization: Eindhoven University of Technology, The Netherlands Newsgroups: microsoft.public.vc.language,comp.lang.c,comp.lang.c++,gnu.g++.help