Question

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)

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top