what type?

Hello,

I am new to c++, still learning and this site is great help. :)
I have dilema about data types and hope someone will help me resolve it. For example, number of 500 billions, I get it it can't be of unsigned int type because it's too large. If I understand right it has to be float. When I print it on screen it is shown as 5e+11. Is that any way to print it in user-friendly form, like 500.000.000.000,00?

Thanks in advance :)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>

using namespace std;

int main()
{
    unsigned int iNumber;
    iNumber = 500000000000;
    cout << iNumber << endl;
    float fNumber;
    fNumber = 500000000000;
    cout << fNumber;
    return 0;
}
Try using [unsigned] long long
You could also use the stream format flags like std::ios::fixed and std::ios::showpoint to show a fixed number of digits after the decimal point and set setprecision() to the proper "length". But if you also want the comma and decimal point to show you'll probably need to do the formatting yourself.

Thanks a lot for help.

I didn't know there is long long type, that will help a lot. And for detailed formating this showpointand fixed with setprecision() thing will be usefull.

Be well
Topic archived. No new replies allowed.