Problem with float values printing

M

matekm

I have program that prints float values (I need this for testing). And
it works almost fine. The thing is that when I want to print 1e-01
(for example) it prints 1e-01 on Linux (g++) and 1e-001 on Windows
(Visual Studio 2008, default empty solution). Is there any way to
standarise this? I would like that on Win and on Lin std::cout print
1e-01.

Thanks for help!
Robert M
 
V

Victor Bazarov

matekm said:
I have program that prints float values (I need this for testing). And
it works almost fine. The thing is that when I want to print 1e-01
(for example) it prints 1e-01 on Linux (g++) and 1e-001 on Windows
(Visual Studio 2008, default empty solution). Is there any way to
standarise this? I would like that on Win and on Lin std::cout print
1e-01.

*I* think there is a defect in VS2008 (that has existed since who knows
when) that causes it to print three zeros when only two should be
printed (C Standard, description of 'fprintf', 'f,F' conversion
specifier. Try asking about it in 'microsoft.public.vc.language'.

If you want to make sure you always have the right number of digits, try
forming the string yourself (yes, it's tedious).

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,072
Latest member
trafficcone

Latest Threads

Top