![]() |
Masm32 adding two floats
I have an array of floats working already. Now all I want to do is add the floats together then get the average.
Say I have two floats, float1 and float2. How do I add those and average them? Thanks for any help. I can't find much help through google, most stuff has detailed explanations which I don't understand rather than examples. |
Re: Masm32 adding two floats
Try something like this.
:
fld float1; Loads the first float on the float stack |
Re: Masm32 adding two floats
appreciate it man. already figured it out but I wasn't near a computer so couldn't let people know it was solved. although this is still helpful because my algorithm was different than the one you put above, so its good info to know.
|
Re: Masm32 adding two floats
wow I completed the project. 20+ hours working on it. then RIGHT as I finished, my professor emails the whole class saying he 'discovered a problem he hasnt figured out how to fix' so to 'hand in what you have and hell grade it easier' . really nice except i GOT IT RIGHT.
fuck. |
Re: Masm32 adding two floats
wow I completed the project. 20+ hours working on it. then RIGHT as I finished, my professor emails the whole class saying he 'discovered a problem he hasnt figured out how to fix' so to 'hand in what you have and hell grade it easier' . really nice except i GOT IT RIGHT.
fuck. |
Re: Masm32 adding two floats
Perhaps he'll go ahead and give you 110%?
|
Re: Masm32 adding two floats
Actually I was incorrect in saying that I got it right. He might not notice and still give me extra credit though, depending on how harsh his input testing is. But it shouldn't be that harsh since he said in class that if you gave a 'good faith effort' you would get 100. Apparently a lot of people couldn't even read in the values from the user. For some reason, my code worked as long as the user entered 42 values or less (although the project description said to let them enter up to 100). But if the user entered > 42 values, the code didn't give the right answer anymore. My friend looked at it and tried to fix it (his project worked completely) and couldn't figure out what was different that it didn't work. When he got done changing some shit around, it only accepted up to 40 values while working correctly. This was all tried on my machine - I'm not sure if that matters. I'm going to post the code, I'm hoping someone can try to run it and see if it works for you.... also, maybe someone can spot an error that causes this problem. Its looping through the "correct number of times" in all cases... it just generates the wrong results when you enter more than 40 values.
This post is the full code. Below this post, I'm posting some 'areas of interest' that i think could possibly be causing it. Of course, I don't know that for a fact otherwise I'd have fixed it, so it could be anywhere, really. But I tried some print statements and such to make sure values are what I expected, and they are...so i don't know whats going on. :
; |
Re: Masm32 adding two floats
Also, the part of the code that seems to be causing the problem is in calculateAvg. When I'm printing out the value that the user entered, its saying I entered values which I never entered. That leaves two possibilities: either some of the values are being read into the array wrong, or some of the values are being read back out of the array wrong. either way, that means my algorithm for doing one or the other is incorrect.
|
| All times are GMT -5. The time now is 2:15 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC