Subj : Re: Any help on why? To : borland.public.cpp.borlandcpp From : waking Date : Wed Jul 07 2004 11:55 am On Wed, 7 Jul 2004 02:53:38 -0400, "Stan DeGroff" wrote: >I wanted to look at the data as a Hexadecimal floating pt. number. As I said: %X is for use with *integer* arguments, not with floats/doubles. >"result" worked ok with %X. "xresult" returned 0 in either format. The result seen when you use incorrect matching of type specifiers with arguments in the *printf and *scanf functions is undefined. It may do *anything*. With Turbo C++ 3.0, your original program with the printf("%d %X, %X\n", i, xresult, result); shows this: GIven an argument: 1.5 The number of arguments is : 1 0 0, 0 The result returned bu AddDouble() is: 1.5 Given arguments: 1.5 and 2.5 The number of arguments is : 2 0 0, 0 1 0, 0 The result returned by AddDouble() is 4.0 Given arguments: 1.5, 2.5 and 3.5 The number of arguments is : 3 0 0, 0 1 0, 0 2 0, 0 The result returned by AddDouble() is 7.5 Given arguments: 1.5, 2.5, 3.5 and 4.5 The number of arguments is : 4 0 0, 0 1 0, 0 2 0, 0 3 0, 0 The result returned by AddDouble() is 12.0 When changed to: printf("%d %f, %f\n", i, xresult, result); it shows this: GIven an argument: 1.5 The number of arguments is : 1 0 1.500000, 1.500000 The result returned bu AddDouble() is: 1.5 Given arguments: 1.5 and 2.5 The number of arguments is : 2 0 1.500000, 1.500000 1 2.500000, 4.000000 The result returned by AddDouble() is 4.0 Given arguments: 1.5, 2.5 and 3.5 The number of arguments is : 3 0 1.500000, 1.500000 1 2.500000, 4.000000 2 3.500000, 7.500000 The result returned by AddDouble() is 7.5 Given arguments: 1.5, 2.5, 3.5 and 4.5 The number of arguments is : 4 0 1.500000, 1.500000 1 2.500000, 4.000000 2 3.500000, 7.500000 3 4.500000, 12.000000 The result returned by AddDouble() is 12.0 -- Wayne A. King (waking@idirect.com, Wayne_A_King@compuserve.com) .