gmp_or()是PHP中的一個內置函數,用於計算兩個GMP數字的按位“或”(GNU Multiple Precision:適用於大數)。
用法:
gmp_or($num1, $num2)
參數:此函數接受兩個GMP編號$num1,$num2作為強製參數,如上麵的語法所示。這些參數可以是PHP 5.6及更高版本中的GMP對象,或者也可以傳遞數字字符串,以便可以將這些字符串轉換為數字。
返回值:此函數返回一個GMP編號,該編號是作為參數傳遞給它的GMP編號的按位或。
例子:
Input : gmp_or("4", "2")
Output : 6
Input : gmp_or("9", "10")
Output : 11
以下示例程序旨在說明PHP中的gmp_or()函數:
程序1:程序將數字字符串作為GMP數字作為參數傳遞時,計算GMP數字的按位或。
<?php 
// PHP program to calculate the bitwise OR 
//  GMP numbers passed as arguments  
  
// strings as GMP numbers  
$num1 = "10"; 
$num2 = "9"; 
  
// calculate the bitwise OR of $num1 and $num2 
$res = gmp_or($num1, $num2); 
  
echo $res; 
  
?>輸出:
11
程序2:當GMP數字作為參數傳遞時,計算GMP數字的按位或的程序。
<?php 
// PHP program to calculate the bitwise OR 
//  GMP numbers passed as arguments  
  
// creating GMP numbers using gmp_init() 
$num1 = gmp_init(4); 
$num2 = gmp_init(2); 
  
// calculate the bitwise OR of $num1 and $num2 
$res = gmp_or($num1, $num2); 
  
echo $res; 
  
?>輸出:
6
參考:
http://php.net/manual/en/function.gmp-or.php
相關用法
- p5.js sq()用法及代碼示例
 - d3.js d3.map.has()用法及代碼示例
 - PHP next()用法及代碼示例
 - p5.js day()用法及代碼示例
 - p5.js pow()用法及代碼示例
 - CSS var()用法及代碼示例
 - d3.js d3.map.set()用法及代碼示例
 - PHP pow( )用法及代碼示例
 - PHP pi( )用法及代碼示例
 - PHP Ds\Map get()用法及代碼示例
 - PHP Ds\Map put()用法及代碼示例
 - p5.js str()用法及代碼示例
 
注:本文由純淨天空篩選整理自akash1295大神的英文原創作品 PHP | gmp_or() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
