cylam1000
asked on
Why can't pow(10,1/3) display correctly?
Why can't pow(10,1/3) display correctly?
How to improve the part of pow function?
How to improve the part of pow function?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Just a slight clarification on the comment from ksboyz, it looks like a typo where the parenthesis are in the wrong place.
pow(10, (float)(1/3)) will not correctly cast 1/3 to the float number 0.3333.... Instead it will cast the integer result of 1/3 (which is 0) to a float which will be 0.0.
The correct cast is pow(10, ((float)1)/3);
Either the 1 or the 3 must be a floating point type before the divison.
pow(10, (float)(1/3)) will not correctly cast 1/3 to the float number 0.3333.... Instead it will cast the integer result of 1/3 (which is 0) to a float which will be 0.0.
The correct cast is pow(10, ((float)1)/3);
Either the 1 or the 3 must be a floating point type before the divison.
Or even better...
Simply write: pow(10,1.0/3)
:)
Simply write: pow(10,1.0/3)
:)
or the pow(10,1/3/0) that I put in the first response :-)
Sorry, :) Didn't see that.
No comment has been added lately and this question is therefore classified abandoned.
If asker wishes to close the question, then refer to
https://www.experts-exchange.com/help/closing.jsp
Otherwise, I will leave a recommendation in the Cleanup topic area that this question is:
PAQed with A grade to odog1999
Please leave any comments here within the next seven days. It is assumed that any participant not responding to this request is no longer interested in its final disposition.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
Sunny
EE Cleanup Volunteer
If asker wishes to close the question, then refer to
https://www.experts-exchange.com/help/closing.jsp
Otherwise, I will leave a recommendation in the Cleanup topic area that this question is:
PAQed with A grade to odog1999
Please leave any comments here within the next seven days. It is assumed that any participant not responding to this request is no longer interested in its final disposition.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
Sunny
EE Cleanup Volunteer
from
ksboyz