Jan 25, 2013 at 1:37pm Jan 25, 2013 at 1:37pm UTC
Whats the symbol for divide
In C++
Last edited on Jan 25, 2013 at 1:39pm Jan 25, 2013 at 1:39pm UTC
Jan 25, 2013 at 1:43pm Jan 25, 2013 at 1:43pm UTC
/
Docs: http://www.cplusplus.com/doc/tutorial/operators/
Last edited on Jan 25, 2013 at 1:44pm Jan 25, 2013 at 1:44pm UTC
Jan 25, 2013 at 4:32pm Jan 25, 2013 at 4:32pm UTC
If use is:
int a=10;
float b=8;
Then:
b/a = 0 integer division
b/(double a) = 0.8
I think this is your problem
Jan 25, 2013 at 4:49pm Jan 25, 2013 at 4:49pm UTC
@tmihos
b/a will return approximately 0.8 as a float because b is a float. What you said would be true if b was an integer.
Jan 25, 2013 at 5:09pm Jan 25, 2013 at 5:09pm UTC
Peter87 is right: The second variable is converted to the type of the first variable with built-ins.
Jan 25, 2013 at 6:31pm Jan 25, 2013 at 6:31pm UTC
@EssGeEich: a/b
will give you `1.25'
Jan 25, 2013 at 9:24pm Jan 25, 2013 at 9:24pm UTC
I think they assume there must be more to your question. The symbol for divide in C++ is the forward slash /
. Just like in every other language (and in first grade arithmetic). Is that really what you're asking???
EDIT: OK, technically first graders used that dash with the two dots above and below but it's too easy to confuse with the plus sign and it isn't on a computer keyboard.
Last edited on Jan 25, 2013 at 9:26pm Jan 25, 2013 at 9:26pm UTC
Jan 26, 2013 at 4:33pm Jan 26, 2013 at 4:33pm UTC
@Program Programmer
Because you have the correct symbol for division, try to see what is the problem :-)