When I try to display a number like .02, it shows as 0.0. How can I fix that? Thanks
When I try to display a number like .02, it shows as 0.0. How can I fix that? Thanks
What code are you using to display it?
Pentium 4 - 2.0GHz, 512MB RAM
NVIDIA GeForce4 MX 440
WinXP
Visual Studio .Net 2003
DX9 October 2004 Update (R.I.P. VC++ 6.0 Compatability)
Code:std::cout << .02 << std::endl;
I've really gotta stay out of the C++ forum (I know nothing about these commands)
But some quick tutorial searches on Google and testing showed me that:
Displays:Code:#include <iostream> using namespace std; int main(void) { std::cout <<.02<< std::endl; return 0; }
0.02
Press any key to continue
And
Displays:Code:#include <iostream> using namespace std; int main(void) { std::cout <<".02"<< std::endl; return 0; }
.02
Press any key to continue
So, to answer your question, I don't know what the problem is.
EDIT:
The difference is with the quotation marks in the cout line.
Last edited by Epo; 07-04-2005 at 08:30 PM.
Pentium 4 - 2.0GHz, 512MB RAM
NVIDIA GeForce4 MX 440
WinXP
Visual Studio .Net 2003
DX9 October 2004 Update (R.I.P. VC++ 6.0 Compatability)
Try this, your answer should be on the 3rd page of the pdf,
Formatting Stream Outputs
Or...
you could simply do
Code:cout << .02f << endl;Code:cout << (float).02 << endl;Code:cout << static_cast<float>(.02) << endl;