0

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

4
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by vmanes
0
cout.setf(std::ios_base::fixed,std::ios_base::floatfield);
int someNumber  = 10;
cout.precision( someNumber );
0

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 );
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.