Forum Discussion
chayal
Mar 30, 2022Copper Contributor
sprintf giving different results when used in vs2013 and vs2019.
Hi Team,
I have a sample code wherein I am converting a double to string using sprintf.
The same code is used in two different code bases, one of which is compiled using vs2013 and other using vs2019. I see different results in both the case. Following is the piece of code:
sprintf(buf, p > 0 ? "%#.*f" : "%.*f", p, d);
where p=8 and d is variable of type double and its value is 11111111111222222222222222. buf is char array of size 320
Observation:
Value of buf in vs2019 1111111111111222163202874213048930610238868946944.00000000
value of buf in vs2013:
11111111111222222000000000.00000000
Can you please explain. Also what can we use as a replacement of sprintf?
No RepliesBe the first to reply