Subj : Re: Any help on why? To : borland.public.cpp.borlandcpp From : waking Date : Sat Jul 10 2004 09:30 pm On Fri, 9 Jul 2004 02:39:17 -0400, "Stan DeGroff" wrote: >The %LX deal works, but I can see that size and alignment are issues which >may be hard to nail down and control from the programmer side of the >compiler Be aware as well when trying to peek inside a float by bypassing the compiler's public and formal interfaces to floats that different compilers and different platforms may use different float formats. While Borland and Microsoft C/C++ apparently both follow the IEEE spec, Microsoft BASIC uses a different format (Microsoft Binary - MSB). So if you have files created using BASIC which stored floats/doubles, you may have to convert them if reading the files from a C/C++ program. Microsoft's C/C++ compilers provide functions in their RTL for converting between the two formats: fieeetomsbin() converts IEEE float to Microsoft float fmsbintoieee() converts Microsoft float to IEEE float dieeetomsbin() converts IEEE double to Microsoft double dmsbintoieee() converts Microsoft double to IEEE double These aren't in Borland's RTL. A public domain version (msb2ieee.c) is available in the Snippets collection (http://www.snippets.org), and there is a Borland TID on the topic (which showcases the C bit-wise operators to considerable advantage, as well as the use of casting pointers to floats to pointers to unsigned chars): "Converting between Microsoft Binary and IEEE" http://www.vmlinux.org/~jakov/community.borland.com/16431.html P.S. - I believe there was/is also a Pascal 6-byte version. (Good luck with your C endeavours. If you have any more questions, pop back here.) -- Wayne A. King (waking@idirect.com, Wayne_A_King@compuserve.com) .