0

Hi,

I have been trying to figure this out and I know it must be something simple but I cant get it. Why does the following code give an answer of 1.

double a=8;
cout<<pow(a,1/3);

I would think it should be 2.
Thanks

3
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by rudasi
0

Thanks, i forgot about that :) .It gets truncated.
Thanks once again.

0

Thanks, i forgot about that :) .It gets truncated.
Thanks once again.

Just to clarify (words mean things)

What you've got is the result of integer division.

Truncation is what happens when you assign a floating point value that has a fractional part to an integer variable, or typecast the floating point to an integer type.

0

Thanks, Thats absolutely right.

Just to clarify (words mean things)

What you've got is the result of integer division.

Truncation is what happens when you assign a floating point value that has a fractional part to an integer variable, or typecast the floating point to an integer type.

This question has already been answered. 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.