ฟังก์ชัน bcpow() ใช้ยกเลขฐาน (base) arbitrary precision ไปยังเลขชี้กำลัง (exponent) รับค่า 2 ตัวเป็น string คืนค่าผลลัพธ์หลังปัดเศษตาม precision
รูปแบบการใช้งาน (Syntax)
string bcpow(string $base, string $exponent, int $scale = 0)
พารามิเตอร์
- $base – เลขฐาน (base) string
- $exponent – เลขชี้กำลัง (exponent) string
- $scale – จำนวนหลักทศนิยมในผลลัพธ์ (default 0)
ค่าที่คืนกลับ
คืนค่า BaseExponent
ตัวอย่าง 1: ไม่ใช้ scale
<?php $base = "5"; $exponent = "7"; $result = bcpow($base, $exponent); echo "The output is: " . $result; ?>
ผลลัพธ์
The output is: 78125
ตัวอย่าง 2: ใช้ scale = 3
<?php $base = "2"; $exponent = "3"; $scaleval = 3; $result = bcpow($base, $exponent, $scaleval); echo "Output with scale value: " . $result; ?>
ผลลัพธ์
Output with scale value: 8.000