Symbol

Jan 25, 2013 at 1:37pm
Whats the symbol for divide
In C++
Last edited on Jan 25, 2013 at 1:39pm
Jan 25, 2013 at 1:43pm
closed account (3TXyhbRD)
/

Docs: http://www.cplusplus.com/doc/tutorial/operators/
Last edited on Jan 25, 2013 at 1:44pm
Jan 25, 2013 at 4:32pm
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
@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
Peter87 is right: The second variable is converted to the type of the first variable with built-ins.
Jan 25, 2013 at 6:31pm
@EssGeEich: a/b will give you `1.25'
Jan 25, 2013 at 7:06pm
ne555 wrote:
@EssGeEich: a/b will give you `1.25'

Oh. :/
Jan 25, 2013 at 7:10pm
what are guys taking about? i just needed to know whats the divide sign in C++ for my calculator. http://www.cplusplus.com/forum/general/90851/
Jan 25, 2013 at 9:24pm
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:36pm
Is this guy all right?
Jan 26, 2013 at 4:33pm
@Program Programmer

Because you have the correct symbol for division, try to see what is the problem :-)
Topic archived. No new replies allowed.