Subj : Re: Any help on why? To : borland.public.cpp.borlandcpp From : waking Date : Wed Jul 07 2004 06:10 pm On Wed, 07 Jul 2004 07:36:44 -0700, Bob Gonder wrote: >What if you want to see how a float works? Then you dump it as raw bytes (chars), not by using a type specifier in a lib function which is intended for a different type. The compiler implementors are allowed to assume that the correct argument type will be passed. Since doubles and ints are different sizes, and different internal layouts, passing doubles where ints are expected can only lead to unpredictable behavior. >Hex output is quite reasonable for such. Indeed. (On a machine which has byte sizes which are a multiple of 4. On others octal may be more appropriate.) >%X takes BYTES off the stack and displays them. It doesn't care what >type they were before they got put on the stack. Where did you get that notion from? Show me where it says that in the ISO/ANSI specs for the C/C++ Standard Libraries. You're making assumptions about implementation details, which may vary from compiler to compiler. You're ignoring the fact that C and C++ are languages which have extensive formal specifications. The language specifies what is valid or invalid. You can't arbitrarily use standard library functions in any way you want (and expect it to work consistently across implementations/platforms.) >Poster could have used %lX for float or double as %X is int, whatever >size that is (target dependant).. When l (lower case L) is used with any of these: d i o u x X then arg is interpreted as a long int. On the platform in question, a long int is 32-bits and a double is 64 bits. Further, since floats/doubles are stored with certain bits used for the mantissa and certain others for the exponent, whereas ints are stored according to the endian architecture of the platform, interpreting a hex dump of a float (mis)interpreted as an int (or vice versa) would be challenging to say the least. -- Wayne A. King (waking@idirect.com, Wayne_A_King@compuserve.com) .