Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 03-19-2006, 12:41 PM   #1
Baseband Member
 
Join Date: Mar 2006
Posts: 39
Default Exponents and Roots

I am pretty new to C++, and i was wondering if there was any way to do exponents and roots. Your time is much appreciated.
__________________

__________________
Don't forget to vote in my pole on who you think will win the Stanley Cup

Go Sens Go!
Nucular is offline   Reply With Quote
Old 03-19-2006, 01:12 PM   #2
Fully Optimized
 
Š88's Avatar
 
Join Date: May 2005
Posts: 4,775
Send a message via MSN to Š88
Default Re: Exponents and Roots

yes, include the cmath library.

Exponents --> exp(x) - where x is the power you want to raise to, or pow(x,y) --> x raised to the power y.

Roots --> sqrt(x) - square root of x
__________________

__________________
Killing under the cloak of war is no different than murder

Kein Alkohol ist auch keine Lösung!
Š88 is offline   Reply With Quote
Old 03-19-2006, 01:20 PM   #3
Baseband Member
 
Join Date: Mar 2006
Posts: 39
Default Re: Exponents and Roots

kk thanks distortion. Can you do cubed roots or fourth roots, or only square roots?
__________________
Don't forget to vote in my pole on who you think will win the Stanley Cup

Go Sens Go!
Nucular is offline   Reply With Quote
Old 03-19-2006, 01:21 PM   #4
Fully Optimized
 
UK31337's Avatar
 
Join Date: Feb 2005
Posts: 2,776
Default Re: Exponents and Roots

To get the square root of a number, all you need to do is raise it to the power of a half.

So, 9^0.5 = sqrt(9) = 3.

But <cmath> is a far more elegant way of doing it, IMHO.
__________________
Master of common sense. If you don't like it, stop reading.
UK31337 is offline   Reply With Quote
Old 03-19-2006, 01:29 PM   #5
Baseband Member
 
Join Date: Mar 2006
Posts: 39
Default Re: Exponents and Roots

I should have known that. Thank-you for enlightening me UK. btw, have you ever golfed at St. Andrew's?
__________________
Don't forget to vote in my pole on who you think will win the Stanley Cup

Go Sens Go!
Nucular is offline   Reply With Quote
Old 03-19-2006, 04:26 PM   #6
Fully Optimized
 
Š88's Avatar
 
Join Date: May 2005
Posts: 4,775
Send a message via MSN to Š88
Default Re: Exponents and Roots

Quote:
Originally Posted by UK31337
To get the square root of a number, all you need to do is raise it to the power of a half.

So, 9^0.5 = sqrt(9) = 3.

But <cmath> is a far more elegant way of doing it, IMHO.
oh yes of course there are other methods to do the same calculations. I do agree though, that cmath does make things so much easier and less work. Programmers, after all, I find are lazy and want to get things done in the quickest way possible with the least amount of code

- ooh, this was my 666th post.....devilish!
__________________
Killing under the cloak of war is no different than murder

Kein Alkohol ist auch keine Lösung!
Š88 is offline   Reply With Quote
Old 03-19-2006, 09:51 PM   #7
Daemon Poster
 
RewtGuy's Avatar
 
Join Date: Dec 2004
Posts: 595
Send a message via AIM to RewtGuy
Default Re: Exponents and Roots

if you want to find other roots you can just raise the number you want to find the root of to the right decimal. for example: cube, = 1/3 .33333 forever, fourth = 1/4 = .25 ect.
__________________

__________________
Windows: A thirty-two bit extension and GUI shell to a sixteen bit patch to an eight bit operating system originally coded for a four bit microprocessor and sold by a two-bit company that can't stand one bit of competition.
RewtGuy is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 03:54 AM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0