Hi,
When using "..printf Functions" with Conversion specifier type "%g", it gives different results under different environment. For example, "sprintf(string,"%g",1e-6);" gives "1e-006" in Windows (Visual C++) and "1e-06" in Linux (gcc). Maybe I am wrong about it. Is it possible to get the same format under whatever operating system or compiler?
Thanks in advance!

Recommended Answers

All 2 Replies

Answer negative. It's one of implementation-defined issues.
However you may write your own double to string conversion function then use it and %s format specifier...

Try atof. See if they get the same answer. As said before it an implemenation issue.

ssharish

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.