Cubic-Roots in C++

How to put a cubic-root in C++ (or is this impossible?)

Page 1 of 1

3 Replies - 8814 Views - Last Post: 10 December 2009 - 07:24 AM Rate Topic: -----

#1 KoenM  Icon User is offline

  • New D.I.C Head

Reputation: -4
  • View blog
  • Posts: 41
  • Joined: 07-December 09

Cubic-Roots in C++

Posted 10 December 2009 - 01:25 AM

Hello,

Does anybody here know how I can put a cubic-root in C++?
Or is this impossible to do?

Thanks in advance!
Is This A Good Question/Topic? 0
  • +

Replies To: Cubic-Roots in C++

#2 EdwinNameless  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 120
  • View blog
  • Posts: 710
  • Joined: 15-October 09

Re: Cubic-Roots in C++

Posted 10 December 2009 - 02:15 AM

View PostKoenM, on 10 Dec, 2009 - 07:25 AM, said:

Hello,

Does anybody here know how I can put a cubic-root in C++?
Or is this impossible to do?

Thanks in advance!


I'll reply here rather than replying to your PM.

It's always possible to get the cubic root in any language if you have an exponentiation function: you just have to remember that cubic root is actually bringing a number to the power 1/3.

#include <iostream>
#include <cmath>
int main() {
  float i = 125.0;
  std::cout << pow(i,(1/3.0))  << std::endl;
}


This post has been edited by EdwinNameless: 10 December 2009 - 02:23 AM

Was This Post Helpful? 0
  • +
  • -

#3 KoenM  Icon User is offline

  • New D.I.C Head

Reputation: -4
  • View blog
  • Posts: 41
  • Joined: 07-December 09

Re: Cubic-Roots in C++

Posted 10 December 2009 - 03:01 AM

View PostEdwinNameless, on 10 Dec, 2009 - 01:15 AM, said:

View PostKoenM, on 10 Dec, 2009 - 07:25 AM, said:

Hello,

Does anybody here know how I can put a cubic-root in C++?
Or is this impossible to do?

Thanks in advance!


I'll reply here rather than replying to your PM.

It's always possible to get the cubic root in any language if you have an exponentiation function: you just have to remember that cubic root is actually bringing a number to the power 1/3.

#include <iostream>
#include <cmath>
int main() {
  float i = 125.0;
  std::cout << pow(i,(1/3.0))  << std::endl;
}


Thanks!
I will try this.
Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6058
  • View blog
  • Posts: 23,496
  • Joined: 23-August 08

Re: Cubic-Roots in C++

Posted 10 December 2009 - 07:24 AM

View PostEdwinNameless, on 10 Dec, 2009 - 04:15 AM, said:

View PostKoenM, on 10 Dec, 2009 - 07:25 AM, said:

Hello,

Does anybody here know how I can put a cubic-root in C++?
Or is this impossible to do?

Thanks in advance!


I'll reply here rather than replying to your PM.


KoenM, do not contact members via PM for programming questions; that is what the forums are for.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1