เมธอด Math.BigMul() ใน C# ใช้ในการคำนวณผลคูณทั้งหมดของตัวเลข 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