Let me try that again, this time with code that compiles and in a more
friendly tone :)
>Martin Sebor wrote:
>
>Yes, although it's not immediately obvious to me what the problem
>is, The first assertion above corresponds to this line:
>
> TEST (T, 1.1, 0, 0, 0, ' ', "", "%g");
>
>I don't see where the test ends up formatting 1.1 as 1.1 using the
>"%g" directive (on AIX, printf("%g", 1.1) produces 1 as expected.
>
Uh, not where I tested [AIX 5.3, XL C/C++ V9.0].
$ cat t.cpp
#include <stdio.h>
#include <stdlib.h>
int main (int argc, char* argv [])
{
const float f = 1 < argc ? atof (argv [1]) : 1.1;
printf ("%g\n", f);
printf ("%.0g\n", f); // should be same as %.1g
printf ("%.1g\n", f);
printf ("%.2g\n", f);
printf ("%.3g\n", f);
printf ("%.4g\n", f);
printf ("%.5g\n", f);
printf ("%.6g\n", f);
printf ("%.7g\n", f);
printf ("%.8g\n", f);
printf ("%.9g\n", f);
return 0;
}
$ xlC t.cpp && a.out 1.1
1.1
1
1
1.1
1.1
1.1
1.1
1.1
1.1
1.1
1.10000002
Travis
>Martin
>
>-----Original Message-----
>From: Travis Vitek [mailto:[EMAIL PROTECTED]
>Sent: Wednesday, March 05, 2008 5:11 PM
>To: [email protected]
>Subject: RE: [PATCH] punct.cpp
>
>
>
>>Martin Sebor wrote:
>>
>>Yes, although it's not immediately obvious to me what the problem
>>is, The first assertion above corresponds to this line:
>>
>> TEST (T, 1.1, 0, 0, 0, ' ', "", "%g");
>>
>>I don't see where the test ends up formatting 1.1 as 1.1 using the
>>"%g" directive (on AIX, printf("%g", 1.1) produces 1 as expected.
>>
>
>Uh, it most certainly does not.
>
> $ cat t.cpp
> #include <stdio.h>
>
> int main (int argc, char* argv [])
> {
> const float f = 1 < argc ? atof (argv [1]) : 1.1;
>
> printf ("%g\n", f);
> printf ("%.0g\n", f); // should be same as %.1g
> printf ("%.1g\n", f);
> printf ("%.2g\n", f);
> printf ("%.3g\n", f);
> printf ("%.4g\n", f);
> printf ("%.5g\n", f);
> printf ("%.6g\n", f);
> printf ("%.7g\n", f);
> printf ("%.8g\n", f);
> printf ("%.9g\n", f);
> return 0;
> }
>
> $ xlC t.cpp && a.out 1.1
> 1.1
> 1
> 1
> 1.1
> 1.1
> 1.1
> 1.1
> 1.1
> 1.1
> 1.1
> 1.10000002
>
>Travis
>
>
>>Martin
>>
>