visual c++ - can't add int or doubles - Overclock.net

Forum Jump: 
 
Thread Tools
post #1 of 8 Old 06-08-2010, 02:12 PM - Thread Starter
4.0ghz
 
computeruler's Avatar
 
Join Date: Mar 2009
Location: PA
Posts: 2,994
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 131
For my final project and I only have about a half more class to work on it. When I add up a bunch of other doubles it gives me an error about binary+ something something cant do this something. I decalred the variable like double^ variable or int^variable. Sense the doubles weren't working I changed some of them to integers and that didn't help either. Bascially the doubles were the prices of stuff. Halp.
computeruler is offline  
Sponsored Links
Advertisement
 
post #2 of 8 Old 06-08-2010, 02:15 PM
Grumpy
 
joemaniaci's Avatar
 
Join Date: Jun 2007
Location: Boulder
Posts: 8,801
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 776
Well make sure you don't mix int's with doubles, or you get weird results.

joemaniaci is offline  
post #3 of 8 Old 06-08-2010, 02:15 PM
Programmer
 
JVene's Avatar
 
Join Date: May 2010
Posts: 955
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 247
Without a sample of your code, we can't tell what you're talking about.
JVene is offline  
Sponsored Links
Advertisement
 
post #4 of 8 Old 06-08-2010, 02:19 PM
nVidia Enthusiast
 
mxthunder's Avatar
 
Join Date: Mar 2009
Location: N. Eaton, OH
Posts: 3,425
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 149
Yeah, a code sample would be nice. You may have to cast the int's into doubles
mxthunder is online now  
post #5 of 8 Old 06-08-2010, 06:23 PM - Thread Starter
4.0ghz
 
computeruler's Avatar
 
Join Date: Mar 2009
Location: PA
Posts: 2,994
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 131
It's at school so I don't have anything. It was all doubles though. Like this:
double^ var1
double^ var2
double^ var3
double^ var4
double^ total
total = var1+var2+var3

Also when I switched some to ints I only tried to add the ones that were ints. Another thing, where should I put the line for the total. Basically theres a bunch of radio buttons on different tabs and you choose one and that gives, say, var1 a number. If I put it in the part of the radio button then they choose something different, the price would be messed up. I was thinking about clicking a button to do it becuase I can't think of any other way.
computeruler is offline  
post #6 of 8 Old 06-09-2010, 06:50 PM - Thread Starter
4.0ghz
 
computeruler's Avatar
 
Join Date: Mar 2009
Location: PA
Posts: 2,994
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 131
Anyone?
computeruler is offline  
post #7 of 8 Old 06-10-2010, 12:55 PM - Thread Starter
4.0ghz
 
computeruler's Avatar
 
Join Date: Mar 2009
Location: PA
Posts: 2,994
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 131
Ok nevermind. I just changed it to floats and it worked.
computeruler is offline  
post #8 of 8 Old 06-12-2010, 07:03 AM
1.3ghz
 
ghell's Avatar
 
Join Date: Mar 2007
Posts: 239
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 19
For your reference, this is called Managed C++. Visual C++ is an IDE. Managed C++ is the .NET language developed by Microsoft based on the C++ syntax.

Because managed C++ is different to ISO/ANSI C++, if you do not make this clear you may not get the answers you want quickly. (I use Visual C++ to write "unmanaged" C++)

I suspect the problem is because of the pointers you are using ("double^"). If you changed it to "float" then you aren't using pointers, and this fixes the problem of dereferencing. If you switched to "float^" then you are probably hiding the problem of 32bit vs 64bit pointers and should keep looking for the problem, as well as testing it on both 32 and 64 bit compiled as "AnyCPU".

AOGen CPU (16 thread) score: 14.773s

ghell is offline  
Reply

Quick Reply

Thread Tools
Show Printable Version Show Printable Version
Email this Page Email this Page


Forum Jump: 

Posting Rules  
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off