warning C4244: 'argument' : conversion from 'double' to 'char', possible loss of data

Reply

Join Date: Jul 2005
Posts: 6
Reputation: webempress is an unknown quantity at this point 
Solved Threads: 0
webempress webempress is offline Offline
Newbie Poster

warning C4244: 'argument' : conversion from 'double' to 'char', possible loss of data

 
0
  #1
Aug 5th, 2005
Can anyone help me convert char to double. Yes, I tried casting, it did not work. Anyway, this is the problem, the variable is declared as type double in the struct(database structure). However, it is defined as type Text in the class I'm modifying.

The variable in the class I'm using must remain that type because it is used by other functions in the class. Please help

Nis
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 1,673
Reputation: Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all 
Solved Threads: 261
Lerner Lerner is offline Offline
Posting Virtuoso

Re: warning C4244: 'argument' : conversion from 'double' to 'char', possible loss of data

 
0
  #2
Aug 5th, 2005
Type Text is probably a string of some sort, rather than type char per se'. This then becomes similar to converting type int to a string, whcih may be in a FAQ somewhere. In any event, I'd try using a stringstream (C++ style) or sprintf() (C style) to convert the double to a string and then convert the string to type Text, if necessary.
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 4,335
Reputation: Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future 
Solved Threads: 236
Team Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: warning C4244: 'argument' : conversion from 'double' to 'char', possible loss of

 
0
  #3
Aug 5th, 2005
Originally Posted by webempress
Can anyone help me convert char to double. Yes, I tried casting, it did not work.
While you're learning to program don't splash casts all over the place to disguise your own errors.
http://www.parashift.com/c++-faq-lit....html#faq-39.1
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 6
Reputation: webempress is an unknown quantity at this point 
Solved Threads: 0
webempress webempress is offline Offline
Newbie Poster

Re: warning C4244: 'argument' : conversion from 'double' to 'char', possible loss of data

 
0
  #4
Aug 5th, 2005
Thanks for the advice and I will not bash casting (cause it does and excellent job) but for this program its not the solution. It solves the run time warnings but logically, it does not generate the likely response.

Do you have any more ides.
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 4,335
Reputation: Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future 
Solved Threads: 236
Team Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: warning C4244: 'argument' : conversion from 'double' to 'char', possible loss of

 
0
  #5
Aug 5th, 2005
Originally Posted by webempress
Thanks for the advice and I will not bash casting (cause it does and excellent job) but for this program its not the solution. It solves the run time warnings but logically, it does not generate the likely response.
You cannot cast a string to an integer or floating point value or vice versa.

Originally Posted by webempress
Do you have any more ides.
Uh, yeah. Follow the link I posted.

Originally Posted by webempress
Thanks for the advice and I will not bash casting (cause it does and excellent job)
List your top 5 things that cast does an excellent job at. I'd speculate that 3-4 of them are used incorrect. (Of course I'd be happy to be wrong.)
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC