35 1234
發新話題

[分享] 《PHP》『數學函式庫』

《PHP》『數學函式庫』round --- 取四拾五入

round

(PHP3 , PHP4)

round ---  取四拾五入

語法 : double round(double val [ , int precision] );

說明 :

傳回四拾五入後val的值。

Example :

<?php

    $foo = round( 3.4 );   // $foo == 3.0

    $foo = round( 3.5 );   // $foo == 4.0

    $foo = round( 3.6 );   // $foo == 4.0
?>

參考 : ceil( )  floor( )


TOP

《PHP》『數學函式庫』sin --- 取正弦值

sin

(PHP3 , PHP4)

sin ---  取正弦值

語法 : float sin(float arg);

說明 :

傳回參數arg的正弦值(徑度)。

參考 : cos( )  tan( )

TOP

《PHP》『數學函式庫』sqrt --- 取平方根值

sqrt

(PHP3 , PHP4)

sqrt ---  取平方根值

語法 : float sqrt(float arg);

說明 :

傳回參數arg的平方根值。

TOP

《PHP》『數學函式庫』srand --- 設定亂數種子

srand

(PHP3 , PHP4)

srand ---  設定亂數種子

語法 : void srand(int seed);

說明 :

設定亂數種子seed。

Example :

<?php

   // seed with microseconds since last "whole" second

   srand((double)microtime()*1000000);

   $randval = rand();

?>

參考 : rand( )  getrandmax( )  mt_rand( )  mt_srand( )  mt_getrandmax( )

TOP

《PHP》『數學函式庫』tan --- 取正切值

tan

(PHP3 , PHP4)

tan ---  取正切值

語法 : float tan(float arg);

說明 :

傳回參數arg的正切值。

參考 : sin( )  cos( )

TOP

 35 1234
發新話題

本站所有圖文均屬網友發表,僅代表作者的觀點與本站無關,如有侵權請通知版主會盡快刪除。