Computer >> 컴퓨터 >  >> 프로그램 작성 >> C#

C#의 Math.BigMul() 메서드

<시간/>

C#의 Math.BigMul() 메서드는 2개의 32비트 숫자의 전체 곱을 계산하는 데 사용됩니다. 이 메서드는 두 숫자가 모두 생성된 Int64 정수를 반환합니다.

구문

다음은 구문입니다 -

public static long BigMul (int val1, int val2);

여기서 val1은 1 st 입니다. 곱할 수인 반면 val2는 2 nd 입니다. 번호.

이제 Math.BigMul() 메서드를 구현하는 예를 살펴보겠습니다. -

using System;
public class Demo {
   public static void Main(){
      int val1 = Int32.MaxValue;
      int val2 = Int32.MaxValue;
      Console.WriteLine("Product of two numbers = " + Math.BigMul(val1, val2));
   }
}

출력

이것은 다음과 같은 출력을 생성합니다 -

Product of two numbers = 4611686014132420609

Math.BigMul() 메서드를 구현하는 또 다른 예를 살펴보겠습니다. -

using System;
public class Demo {
   public static void Main(){
      Int32 val1 = 139897778;
      Int32 val2 = 217878786;
      Console.WriteLine("Product of two numbers = " + Math.BigMul(val1, val2));
   }
}

출력

이것은 다음과 같은 출력을 생성합니다 -

Product of two numbers = 30480758034737508