Computer Science Canada

syntax for math operations?

Author:  AsianSensation [ Wed Sep 10, 2003 7:20 pm ]
Post subject:  syntax for math operations?

how do you use mod and exponents in c++?

*mod as in modular math.

Author:  Catalyst [ Wed Sep 10, 2003 7:29 pm ]
Post subject: 

mod is %
and exponent is the function float pow(float num,float exp) in <math>
avoid pow whenever necessary it can be very very slow (i.e use x*x*x over pow(x,3))

Author:  AsianSensation [ Wed Sep 10, 2003 7:33 pm ]
Post subject: 

so if I want to check if a number is a divisor of another, I do this?

code:

if (num % 5 == 0)
    blah blah blah

Author:  Catalyst [ Wed Sep 10, 2003 7:37 pm ]
Post subject: 

yup just like that

Author:  AsianSensation [ Wed Sep 10, 2003 7:48 pm ]
Post subject: 

cool, thanks Catalyst.

I have another question, how about the square root syntax, and does anyone know a site where I can get a list of the syntax and their uses?

Author:  Mazer [ Wed Sep 10, 2003 8:03 pm ]
Post subject: 

www.cppreference.com

Author:  Catalyst [ Wed Sep 10, 2003 8:09 pm ]
Post subject: 

Square Root is just float sqrt(float n)

heres another good site:

www.cplusplus.com

Author:  AsianSensation [ Wed Sep 10, 2003 8:34 pm ]
Post subject: 

cool, thanks guys.

Author:  naoki [ Sat Sep 20, 2003 2:23 pm ]
Post subject: 

indeed those sites will help negate the AWESOME UNQUESTIONABLE GREATNESS of my comp sci teacher

Author:  Andy [ Sat Sep 20, 2003 10:21 pm ]
Post subject: 

cppreference.com sux, it dont give u much info on the functions...

Author:  naoki [ Sun Sep 21, 2003 12:02 pm ]
Post subject: 

considering the purpose of the site and the lack of any advertisement or help to fund the site, i think cppreference is pretty damned nice to pay for its domain for the content it gives.

also try cprogramming.com and codenewbie.com

Author:  bugzpodder [ Sun Sep 21, 2003 12:28 pm ]
Post subject: 

dodge_tomahawk wrote:
cppreference.com sux, it dont give u much info on the functions...

i like cppreference, in fact i have printed out the whole website so i could use it in CCC - stupid school doesnt even have MSDN


: