2016-08-14 1 views
1

큐브 루트 (0.015*(0.05*0.05))을 어떻게 계산합니까?C# math.pow 큐브 루트 계산

double result = Math.Pow(0.015 * (0.05 * 0.05), 1.0/3.0); 

내가 0.03347 무엇입니까 :

나는 다음과 같은 솔루션을 시도했다. Volframalpha와 같은 계산 : 0.015*(0.05*0.05)^0.330.00207입니다.

내가 뭘 잘못하고 있니?

+0

두 가지 다른 계산 방법입니다. – Enigmativity

+0

두 번째 예'(0.015 * (0.05 * 0.05))^0.33' –

+1

에 괄호가 없습니다. WA -'(0.015 * (0.05 * 0.05))^C# 코드에서와 동일한 결과를 제공합니다. – Enigmativity

답변

0

내가 가진 세 가지 우려 사항이 있습니다.

  1. 당신은 당신의 표현의 한 부분에 Math.Pow()를 활용하고, 그러나 나중에 대화 중에 주어진 식의 첫 번째 부분에서() Math.Sqrt를 사용하는 것이 좋습니다.

  2. 둘째,

  3. 셋째 식의 잘못된 평가를 일으키는 원인이되는 표현 내의 괄호 그룹에 문제가있다, 당신은하지 마십시오 수치 후 'D'문자 접미사를 사용해야합니다 기대되는 결과를 평가하기위한 10 진수 값을 갖는다.

방정식 : (0.3d의 * ((0.0015d * (+ 0.793700526d Math.Sqrt (0.7071068))) + (0.015d Math.Pow * ((0.05d * 0.05d) (1D/3D)))))

코드 :

using System; 

namespace POW 
{ 
    class Program 
    { 
     static void Main(string[] args) 
     { 
      // Corrected calculation derived from comment conversation given by author 
      double myCalculation1 = (0.3 * ((0.0015 * (0.793700526 + Math.Sqrt(0.7071068))) + (0.015 * Math.Pow((0.05 * 0.05), (1/3))))); 

      // d suffix used to ensure the non decimal value is treated as a decimal 
      double myCalculation2 = (0.3 * ((0.0015 * (0.793700526 + Math.Sqrt(0.7071068))) + (0.015 * Math.Pow((0.05 * 0.05), (1d/3d))))); 

      // Output the value of myPow 
      Console.WriteLine("The value of myCalculation is: {0}", myCalculation1); 
      Console.WriteLine("The value of myCalculation is: {0}", myCalculation2); 
     } 
    } 
} 

중요한 규칙에 따라 각 번호 다음에 'D'접미사를 사용하기를 원할 것입니다.