The built-in operators are defined in the source code of the compiler. It shouldn't matter how they are defined as long as they satisfy the requirements of the respective language.
i saw the answer from Cubbi that the operators are defined in the source code of the compiler.
the calculation is in the compiled code or maybe a data file. and he did not say there is no define obviously. maybe you should reread his message
is not like asking for a new keyword. operators are not keyword therefore not like
do not argue if unnecessary
i know how to use % in a source file. stay with the question, do not stray
i did not ask for that
quoted from Esslercuffi, ends before edits to run:
operators are like keywords in that they are implemented directly by the compiler program, and not taken from libraries.
Consider this, is there any header file you would need to include in order to get this to work:
1 2 3 4 5
int main()
{
int x = 2, y = 5, z;
z = y % x;
}
edits to run
1 2 3 4 5 6 7 8 9 10
#include <iostream>
usingnamespace std;
int main()
{
int x = 2, y = 5, z;
z = y % x;
cout << "remainder is " << z;
return 0; // because main is int type
}
or
1 2 3 4 5 6 7 8 9
#include <stdio.h>
int main()
{
int x = 2, y = 5, z;
z = y % x;
printf("remainder is %d", z);
return 0;
}
my point was that nothing was needed to get the math to run. <iostream> and <stdio.h> are only there to facilitate output. I was trying to show that you can do all the calculations without any libraries, thus demonstrating that they are handled intrinsically by the compiler, and not implemented in a library.
the declarations and assignments of variables and calc by % modulus does work without libraries.
without either library declared, some library information would be included with an exe bulid.
i see: __exitclean, __exit, __IOERR, _malloc, __setupio, _setvbuf and more.
dos language c++
the declarations and assignments of variables and calc by % modulus does work without libraries.
What are you talking about? Are you telling me I need to include any arbitrary library to declare a variable? To me this is nonsensical.
The only library you even include is simply for output as mentioned by Esslercuffi. His code does compile by the way. Please click the Gear/Cog next to the code. If it doesn't compile for you, I highly suggest you invest some time and get a new compiler. Unless you are thinking it doesn't compile because there is no output?
Edit after you just did
without either library declared, some library information would be included with an exe bulid.
Would you be a little more clear on what you mean please?
tmason:
What Cubbi is saying is that there is no "define" for the modulus operator in C++, that's part of the compiler itself.
It's like asking where is the #define or #include for the "new" keyword. There is none.
Now, if you would like to know how the modulus operator is implemented, you will need to look at the source code for a C++ compiler.
jt1 response:
i was not asking for a new operator like asking for a new keyword. asked about the calc done to achieve remainder in different words. don't get hungup too much on wording. respond with an accurate c/c++ reference to subject and give calc info or web site to calc info. % is a standard operator for a long time now.
some arguments here are tiring
Esslercuffi (77)
operators are like keywords in that they are implemented directly by the compiler program, and not taken from libraries.
ok everyone calm down, there may just be a bit of a language barrier that's causing some confusion. If all you're looking for is an example of the calculations done to get a modulo, Giblit had it several posts ago
giblit (3375)
jt1 wrote:
the declarations and assignments of variables and calc by % modulus does work without libraries.
What are you talking about? Are you telling me I need to include any arbitrary library to declare a variable? To me this is nonsensical.
jt1 response:
did you read the text? i said, "without libraries". subtract the arbitrary, forget the library,
and assign variables without #include. specifically without <iostream> and <stdio.h> get some glasses! and hold the nonsensical. go back to elementary school if accepted.
grumble. giblit actually responded to that.
giblit wrote:
The only library you even include is simply for output as mentioned by Esslercuffi. His code does compile by the way. Please click the Gear/Cog next to the code. If it doesn't compile for you, I highly suggest you invest some time and get a new compiler. Unless you are thinking it doesn't compile because there is no output?
Edit after you just did
without either library declared, some library information would be included with an exe bulid.
Would you be a little more clear on what you mean please?
jt1 response:
the code was run on cpp.sh by click the cog to right. the code did compile and executed
without output to screen.
example 1. works if 2.5 rounded down
a % b = 5 - (2 * (2.5))
a % b = 5 - (2 * (2))
a % b = 5 - 4 = 1 correct value
this is the equation from microsoft excel almost same except for variables to
giblet's original equation.
n - d is number - divisor
INT is the equation that rounds down (n/d) to integer