Float to CString problem
-
Hi sir, I am finding the pow of some values,If it is for smaller values,i am getting the result properly. But if for larger values like (where result will be like2.20700e+007) I am using this code:
result = pow(temp1,temp3);
res.Format("%2d",result);
result is in float and i am getting value as 2.20700e+007 then i am trying to convert it into CString,so that i can tokenize the result in this way(2.20700) But i am getting junk values while converting,its not converting properly. Am i doing any thing wrong or any other way to convert it to CString,where i can get the value properly Thanks Raj
-
Hi sir, I am finding the pow of some values,If it is for smaller values,i am getting the result properly. But if for larger values like (where result will be like2.20700e+007) I am using this code:
result = pow(temp1,temp3);
res.Format("%2d",result);
result is in float and i am getting value as 2.20700e+007 then i am trying to convert it into CString,so that i can tokenize the result in this way(2.20700) But i am getting junk values while converting,its not converting properly. Am i doing any thing wrong or any other way to convert it to CString,where i can get the value properly Thanks Raj
as you said, you are going to operate on larger values, the problem should be that, your resultant value is exceeding the 4 byte boundary, and you are getting improper result. by the way, what are the values you are passing to pow? what is the result you are getting, and what is the result you are expecting?
-------------------------------------------- Suggestion to the members: Please prefix your main thread subject with [SOLVED] if it is solved. thanks. chandu.
-
as you said, you are going to operate on larger values, the problem should be that, your resultant value is exceeding the 4 byte boundary, and you are getting improper result. by the way, what are the values you are passing to pow? what is the result you are getting, and what is the result you are expecting?
-------------------------------------------- Suggestion to the members: Please prefix your main thread subject with [SOLVED] if it is solved. thanks. chandu.
chandu004 wrote:
what are the values you are passing to pow?
The value varies,depends on some condition. ex: pow(0.2365,-0.3445)....
chandu004 wrote:
what is the result you are getting
result = pow(temp1,temp3); // Here i a am getting the result as 2.20700e+007
chandu004 wrote:
what is the result you are expecting?
I am expecting the same result in CString res.Format("%2d",result); // here i am getting some junk values in res. I hope i cleared u Thanks Raj
-
Hi sir, I am finding the pow of some values,If it is for smaller values,i am getting the result properly. But if for larger values like (where result will be like2.20700e+007) I am using this code:
result = pow(temp1,temp3);
res.Format("%2d",result);
result is in float and i am getting value as 2.20700e+007 then i am trying to convert it into CString,so that i can tokenize the result in this way(2.20700) But i am getting junk values while converting,its not converting properly. Am i doing any thing wrong or any other way to convert it to CString,where i can get the value properly Thanks Raj
-
chandu004 wrote:
what are the values you are passing to pow?
The value varies,depends on some condition. ex: pow(0.2365,-0.3445)....
chandu004 wrote:
what is the result you are getting
result = pow(temp1,temp3); // Here i a am getting the result as 2.20700e+007
chandu004 wrote:
what is the result you are expecting?
I am expecting the same result in CString res.Format("%2d",result); // here i am getting some junk values in res. I hope i cleared u Thanks Raj
look at the following url. http://www.elook.org/programming/c/pow.html[^] there he says that, There's a domain error if base is zero and exp is less than or equal to zero i think you may have to do some workaround on this.
-------------------------------------------- Suggestion to the members: Please prefix your main thread subject with [SOLVED] if it is solved. thanks. chandu.
-
Hi sir, I am finding the pow of some values,If it is for smaller values,i am getting the result properly. But if for larger values like (where result will be like2.20700e+007) I am using this code:
result = pow(temp1,temp3);
res.Format("%2d",result);
result is in float and i am getting value as 2.20700e+007 then i am trying to convert it into CString,so that i can tokenize the result in this way(2.20700) But i am getting junk values while converting,its not converting properly. Am i doing any thing wrong or any other way to convert it to CString,where i can get the value properly Thanks Raj