¿Le resultó útil esta página?
Sus comentarios sobre este contenido son muy importantes. Háganos saber su opinión.
¿Tiene comentarios adicionales?
Caracteres restantes: 1500
Exportar (0) Imprimir
Expandir todo
div
eof
Expandir Minimizar
Importante Es posible que este documento no represente los procedimientos recomendados para el desarrollo actual. Puede que los vínculos a las descargas y otros recursos ya no sean válidos. Encontrará aquí la versión que se recomienda en la actualidad.

_set_output_format

Customizes output formats used by formatted I/O functions.


unsigned int _set_output_format(
   unsigned int format
);

[in] format

An value representing the format to use.

The previous output format.

_set_output_format is used to configure the output of formatted I/O functions such as printf. At present, the only formatting convention that can be changed by this function is the number of digits displayed in exponents in the output of floating point numbers.

By default, the output of floating point numbers by functions such as printf, wprintf, and related functions in the Visual C++ Standard C library prints three digits for the exponent, even if three digits are not required to represent the value of the exponent. Zeroes are used to pad the value to three digits. _set_output_format allows you to change this behavior so that only two digits are printed in the exponent unless a third digit is required by the size of the exponent.

To enable two-digit exponents, call this function with the parameter _TWO_DIGIT_EXPONENT, as shown in the example. To disable two digit exponents, call this function with an argument of 0.

Routine

Required header

_set_output_format

<stdio.h>

For more compatibility information, see Compatibility in the Introduction.

Not applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples.

// crt_set_output_format.c
#include <stdio.h>

void printvalues(double x, double y)
{
   printf("%11.4e %11.4e\n", x, y);
   printf("%11.4E %11.4E\n", x, y);
   printf("%11.4g %11.4g\n", x, y);
   printf("%11.4G %11.4G\n", x, y);
}


int main()
{
   double x = 1.211E-5;
   double y = 2.3056E-112;
   unsigned int old_exponent_format;

   // Use the default format
   printvalues(x, y);

   // Enable two-digit exponent format
   old_exponent_format = _set_output_format(_TWO_DIGIT_EXPONENT);

   printvalues(x, y);

   // Disable two-digit exponent format
   _set_output_format( old_exponent_format );

   printvalues(x, y);
}
1.2110e-005 2.3056e-112
1.2110E-005 2.3056E-112
 1.211e-005  2.306e-112
 1.211E-005  2.306E-112
 1.2110e-05 2.3056e-112
 1.2110E-05 2.3056E-112
  1.211e-05  2.306e-112
  1.211E-05  2.306E-112
1.2110e-005 2.3056e-112
1.2110E-005 2.3056E-112
 1.211e-005  2.306e-112
 1.211E-005  2.306E-112

Adiciones de comunidad

AGREGAR
Mostrar:
© 2015 Microsoft