Reputation: 3075
I have a program which shows a different print (an extra 0 on windows) and i am trying to make it same as linux . On windows using Visual studio 2012 . On linux using g++ v4.8.3
Any sugegstion .
I have created a small program to showcase problem that I am facing ...
#include "stdafx.h"
#include <stdio.h>
int main()
{
float f = -1e-14;
printf("\n\n \t Lets print the float value -1e-14 as [%9.3g] \n\n\n\n",f);
return 0;
}
On linux :
/home/mag>./a.out
Lets print the float value -1e-14 as [ -1e-14]
On windows :(notice extra 0 in -1e-014)
Lets print the float value -1e-14 as [ -1e-014]
Reason why I am trying to make it same is because I am debugging some output from windows and linux and huge amount of differences between outputs of windows and linux are due to the problem stated above and I am missing important differences because of these .
Upvotes: 2
Views: 76
Reputation: 798884
Call _set_output_format(_TWO_DIGIT_EXPONENT)
first to cause printf()
to use two-digit exponents with VS2012.
Upvotes: 3