Hello all,
This is my first post in thins forum and I hope a newbie like me makes some sense with my questions.
I have a floating value

float f = 5.3606;

and I output a value

cout<<pow(f,n);

when n goes above 6, the representation of the floating number changes

as I increase n the precision after the decimal point goes on reducing , say after n = 5 , the value is a perfect integer and above that it gives me solution in the scientific format.
I need values in the standard floating point format with precision after the decimal point uncompromised.
What can i do ?

Regards

Ajay Nair

Use manipulators.

cout << setiosflags(ios::fixed)  << pow(f,n);
cout.setf(std::ios_base::fixed,std::ios_base::floatfield);
int someNumber  = 10;
cout.precision( someNumber );

Use type double instead. This will give you about 15 digits precision, compared to a float's 7 digits.

And an alternative to the formatting:

cout.precision(10); //substitute the # digits you want after decimal
	cout << fixed  << showpoint;
        cout << pow( f, n );
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.