Click here to Skip to main content
15,886,963 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi folks,

I'm working on a project, that needs to get the values entered by the user from the "edit box". But when the value is retrieved, just one of the decimal part is retrieved. For eg: The value 23.785 is retrieved as 23.7

C++
double Function1::GetValue()
{
    switch (Type)
  {
 
  case FLOAT:
    return (double)(float)*this;

  case DOUBLE:
    return (double)(double)*this;
}


How do I get the whole number??
Posted
Updated 10-Apr-12 23:54pm
v4
Comments
[no name] 11-Apr-12 4:37am    
How do you know you get 23.7. Have you checked it in the debugger?
Sumal.V 11-Apr-12 4:40am    
Yes. Run my program in debugger.
Code-o-mat 11-Apr-12 4:39am    
You didn't provide enough information for us to be able to say anything. What does (double)(float)*this and (double)(double)*this do? I supose you created operators for your class, show us the code for those, and please don't forget the <pre> tags.
Sumal.V 11-Apr-12 4:43am    
Well I use variable1.GetValue() To get the values from the edit box.

The GetValue() function converts any value from the edit box to a double number.
Code-o-mat 11-Apr-12 4:49am    
All right, but how? Show us the code that does the conversion please.

Well it was a case of assigning double value in float variable!!
 
Share this answer
 
Comments
[no name] 11-Apr-12 7:48am    
Posting a confession of error does not qualify as a solution. This should be in the comments where it belongs. Better still remove the question if possible.
Sumal.V 11-Apr-12 7:53am    
Well there is no option where I can delete the question.
Answered only to remove from unanswered list - solved by OP.
 
Share this answer
 
Comments
Sumal.V 11-Apr-12 7:23am    
Cheers :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900