Sometimes, it is needed to round off a number to some decimal digits. Again stringstream comes to help us with the aid of iomanip function setprecision. Following is a sample function to round off a number to a fixed digits.
double Round(const double value, const int digits) { stringstream stream; // Store the number with required no. of decimal // places to stream stream << setprecision(digits) << value; // Convert stream to number double roundedValue = 0.0; stream >> roundedValue; return roundedValue; }
The header files sstream and iomanip are needed for the above.
Please note that the variable value holds the number with original no. of decimal places and digits is the total number of digits needed (including the non-decimal digits) after rounding has taken place.
Round(10.37665, 3) gives 10.4 and Round(10.3745, 4) gives 10.37.
Note
If you want to store the number in scientific notation in stream, you can do
stream << scientific;
For fixed point format, do
stream << fixed;
Just passing by.Btw, your website have great content!
_________________________________
Making Money $150 An Hour
Пора переименовать блог, присвоив название связанное с доменами 🙂 может хватит про них?
Пора переименовать блог, присвоив название связанное с доменами 🙂 может хватит про них?
Даже и не придирешься!
Спасибо за пост. Позновательно.
Занятно. Хотелось бы еще чего-нибудь об этом же.
Действительно, на самом деле все очень просто 🙂
Увлекательно было почитать 🙂 Попробуем-с тоже ответить в ближайших постах.
Bwc6RO fydyocpgeeko, [url=http://xehytqbdhgjr.com/]xehytqbdhgjr[/url], [link=http://ygxnqifveena.com/]ygxnqifveena[/link], http://zrsjmgbkezcf.com/
http://community.tasteofhome.com/members/Acai_5F00_berries_5F00_side_5F00_affects_5F005F00_66/default.aspx
http://community.tasteofhome.com/members/Cipro_5F00_safer_5F00_to_5F00_take_5F00_than_5F00_doxycycline_5F005F00_87/default.aspx
http://community.tasteofhome.com/members/What_5F00_does_5F00_ultracet_5F00_look_5F00_like_5F005F00_86/default.aspx
http://community.tasteofhome.com/members/Buy_5F00_valium_5F00_without_5F00_a_5F00_prescription_5F005F00_39/default.aspx
http://community.tasteofhome.com/members/Generic_5F00_propecia_5F00_fda_5F00_approved_5F005F00_46/default.aspx
http://community.tasteofhome.com/members/Spinal_5F00_stenosis_5F00_lumbar_5F00_vicodin_5F00_leg_5F00_cramp_5F005F00_23/default.aspx
http://community.tasteofhome.com/members/Meridia_5F00_weight_5F00_loss_5F00_medication_5F005F00_91/default.aspx
http://community.tasteofhome.com/members/Watson_5F00_hydrocodone_5F00_without_5F00_rx_5F005F00_15/default.aspx
Оральный секс – это рассказы приятелям о сексуальных успехах, якобы имевших место…
Вспыхает небо, разбужая ветер,
Проснувший гомон птичьих голосов.
Проклинывая всё на белом свете,
Я вновь бежу в нетоптаность лесов.
Шуршат зверушки, выбегнув навстречу,
Приветливыми лапками маша:
Я среди тут пробуду целый вечер
Бессмертные творения пиша
Но, выползя на миг из тины зыбкой,
Болотная зелёновая тварь
Совает мне с заботливой улыбкой
БОЛЬШОЙ ОРФОГРАФИЧЕСКИЙ СЛОВАРЬ
Люди, учите Русский Язык и пишите ПРАВИЛЬНО.
News. Todays Special Offer Keftab. No Prescription Required. Cheap drugs.
Vicodin From India
Ambien Cr How Much Sleep
Rogaine Foam
Expected Weight Loss With Phentermine
Zyprexa Lawyers San Diego
Hot Sexy Naked Women
Younger Women Seeking Older Men
Dating Bradford
Taking Prevacid With Thyroid
Herbs And Viagra Interaction
Celebrex For Dogs
Diet Pills Ephedrine
Laz0Fn http://gdjI3b7VaWpU1m0dGpvjRrcu9Fk.com