2

I need to run a program that will have a similar output both on Linux and visual studio.

Linux's default width of the exponent field is 2 and visual studio's is 3.

So for a number 3.40282e+38 Linux leaves it as it is, but visual studio pads it with an additional 0, 3.40282e+038

Anyone know how to configure the output in visual studio to remove the zero? (or add a zero in Linux)

wallyk
  • 56,922
  • 16
  • 83
  • 148
user690936
  • 985
  • 5
  • 13
  • 23
  • Here is a similar question, which you can refer to: http://stackoverflow.com/questions/8773133/c-how-to-get-one-digit-exponent-with-printf – endless Apr 02 '12 at 12:14

1 Answers1

2

According to Wikipedia: http://en.wikipedia.org/wiki/Printf_format_string

The exponent always contains at least two digits; if the value is zero, the exponent is 00. In Windows, the exponent contains three digits by default, e.g. 1.5e002, but this can be altered by Microsoft-specific _set_output_format function.

So it looks like you can ask Microsoft's compiler not to add the zero. I don't know about asking gcc to add the zero, though.

Multimedia Mike
  • 12,660
  • 5
  • 46
  • 62