Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 syntax for math operations?
Index -> Programming, C++ -> C++ Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
AsianSensation




PostPosted: 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.
Sponsor
Sponsor
Sponsor
sponsor
Catalyst




PostPosted: Wed Sep 10, 2003 7:29 pm   Post subject: (No 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))
AsianSensation




PostPosted: Wed Sep 10, 2003 7:33 pm   Post subject: (No 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
Catalyst




PostPosted: Wed Sep 10, 2003 7:37 pm   Post subject: (No subject)

yup just like that
AsianSensation




PostPosted: Wed Sep 10, 2003 7:48 pm   Post subject: (No 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?
Mazer




PostPosted: Wed Sep 10, 2003 8:03 pm   Post subject: (No subject)

www.cppreference.com
Catalyst




PostPosted: Wed Sep 10, 2003 8:09 pm   Post subject: (No subject)

Square Root is just float sqrt(float n)

heres another good site:

www.cplusplus.com
AsianSensation




PostPosted: Wed Sep 10, 2003 8:34 pm   Post subject: (No subject)

cool, thanks guys.
naoki




PostPosted: Sat Sep 20, 2003 2:23 pm   Post subject: (No subject)

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




PostPosted: Sat Sep 20, 2003 10:21 pm   Post subject: (No subject)

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




PostPosted: Sun Sep 21, 2003 12:02 pm   Post subject: (No 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
bugzpodder




PostPosted: Sun Sep 21, 2003 12:28 pm   Post subject: (No 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
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 12 Posts ]
Jump to:   


Style:  
Search: