incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Travis Vitek" <Travis.Vi...@roguewave.com>
Subject RE: [PATCH] punct.cpp
Date Thu, 06 Mar 2008 01:10:42 GMT
 

>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
>

Mime
View raw message