![]() |
limiting decimal places
Can some one give me an idea of how to limit decimal spaces from a double.
|
Re: limiting decimal places
aShoe, if you're using the iostream library for output, you need to use the setprecision() manipulator (http://cppreference.com/io_flags.html#manipulators).
Example: :
#include <iostream>Or, if you're using C style output: :
#include <stdio.h> |
Re: limiting decimal places
You can only limit them on output, such as with cout of another output stream
:
double x = 12.1234567890;has the following output :
12.12[edit] I was too slow. what dr.p said[/edit] |
| All times are GMT -5. The time now is 3:35 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC