you need to do this then
c = (int)x%(int)y; //cast the other two vars as ints mod won't work for floats
Printable View
you need to do this then
c = (int)x%(int)y; //cast the other two vars as ints mod won't work for floats
K, it works now. Just need to allow the user to access the function in the first place. Unfortunately, it's giving me an "undeclared" error. *yawn*
EDIT: Hah, its reason for being undeclared was that modulus isn't a legal function name (or so my observations tell me). With my previous plus() and minus() functions, it was probably the same problem! :D
O yea you cant do that lol... Use things like MyModulus :P
I'm just calling it mod(). I'm just gonna assimilate mod() into the division half of diviminus() so that it outputs both the result of division and the remainder, and then I'll be pretty much done with the calculator.
Sounds good to me. I noticed you fixed the double entrys at some point. Forgot to mention that.
Double entries? *confused*
A while back you had to enter y twice to get into the function :P guess it was longer ago than I thought lol.
Oh, yeah. I mentioned that earlier, and said it had to do wit haccedentally calling "cin" twice.
Speaking of bugs, I have a minor but weird one on in the text-based game I'm writing. It's on another topic if you want to take a look.
That will result in loss of precision. If you don't want that, include <math.h> and use the fmod() function. It takes two double [floating-point] arguments and moduluses them.Quote:
you need to do this then
c = (int)x%(int)y;
Code:#include <math.h>
printf("%lf", fmod(10.0, 8.2));
You mean <cmath> and cout, right? THis is the C++ part of the board. Thanks, though. ^_^ (if you can't tell, ^_^ is a smiley).
EDIT: Hey, that works pretty well! I just implemented it. :D
Sorry, and you're welcome. :)