You are here:

C++/result in decimal order


hi can u help me. i want answer in desimal digits. for example. i product two large numbers like (22222 * 33333 = )it answer me in exp form like that ( = 123456 e^123456123) . but i want answer in linear form like ( = 123456789... ) with out exp or power of 10. i want sample. or code in detail. please help me out.

You can easily format your output so that fields align correctly, floating point numbers have the representation and precision that you need, your numbers justified the way you want and so on. To do this you have to set the appropriate format flags for the stream - by using the member functions or 'manipulators' provided in <iostream> and <iomanip>

Here is a brief example on formatting floating point numbers using manipulators:

#include <iostream>
#include <iomanip>

int main()
   double number = 22222.0 * 33333.0 ;
   std::cout << number << '\n' // 7.40726e+08
         << std::fixed << number << '\n' // 740725926.000000
         << std::setprecision(2) << number << '\n' // 740725926.00
         << std::setprecision(0) << number << '\n' // 740725926
         << std::showpoint << number << '\n' // 740725926.
         << std::noshowpoint << number << '\n' ; // 740725926

For more information and examples, see:


All Answers

Answers by Expert:

Ask Experts




my primary areas of interest are generic and template metaprogramming, STL, algorithms, design patterns and c++11. i would not answer questions about gui and web programming.


about 15 years or so

post graduate engineer

©2016 All rights reserved.