Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!asuvax!hrc!gtephx!robertsw From: robertsw@...!asuvax!gtephx (Wild Rider) Newsgroups: comp.lang.c Subject: Re: Floating point format conversion? Message-ID: <1991Apr29.190528.1061@...!asuvax!gtephx> Date: 29 Apr 91 19:05:28 GMT References: <1991Apr25.203121.11130@ericsson.se> Reply-To: robertsw@gtephx.UUCP (Wild Rider) Organization: AG (formerly GTE) Comm. Sys., Phx, AZ Lines: 50 i tried email, but (alas), it bounced; here's the text: In article <1991Apr25.203121.11130@ericsson.se> writes: > >Hi, > >I have a data file which was written using Micrsoft binary format for >floating point numbers. On a PC this is not a problem because the >microsoft C libraries have a function to convert the MSC binary format >to IEEE binary format. > >I am looking for a function to perform this same function on a Sun >workstation running SunOS 4.1.1. Does anyone have the source code >for this type of function or know the algorithm for such a conversion? > uh, well, if it were me, being the lazy scumbag that i am :-), i'd simply do the conversion on the pc side using the microsoft conversion function, then ship the converted data to the sun. but, i suppose, you already have the data on the sun & have no way of getting it to the pc & back? hmm... well, then, you _do_ have a problem, don't you... if you have the intestinal fortitude, you can write a function in c to do the trick; i had to convert ibm (mainframe) floating point to ieee & was able to do it in c pretty easily, once i had the specs for the 2 formats. all you need to do is declare a bitfield struct for each format, then push the bits around as necessary. for example, i believe the following struct pretty much describes an ieee floating point value: typedef struct { ieee_sign unsigned:1; ieee_exp unsigned:8; ieee_mantissa unsigned:23; } ieee_t; btw, don't forget the "hidden bit" when you're doing the conversion... all this makes more sense when you're looking at the specs. hope this helps... wr (wild rider) -- Wallace Roberts, AG (formerly GTE) Communication Systems, Phoenix, AZ UUCP: ...!{ncar!noao!asuvax | uunet!zardoz!hrc | att}!gtephx!robertsw Internet: gtephx!robertsw@asuvax.eas.asu.edu Bike: '82 GS1100L Suz voice: (602)581-4555 fax: (602)582-7624 Cage: '89 Mustang GT