Fungsi hipot() PHP
定义和用法
hypot()函数计算直角三角形的斜边长度。斜边的计算公式如下:
h=sqrt(x2+y2),其中x和y是直角三角形的另外两条边
例如,如果x=3,y=4,那么hypot(x,y)=5,即sqrt(32+42) = sqrt(25) =5
该函数总是返回一个浮点数。
语法
hypot ( float $x , float $y ) : float
参数
序号 | 参数和说明 |
---|---|
1 | x 直角三角形的一边 |
2 | y 直角三角形的另一边 |
返回值
PHP hypot() 函数返回给定 x 和 y 值的直角三角形的斜边长度
PHP 版本
此函数在 PHP 版本 4.x、PHP 5.x 和 PHP 7.x 中可用。
示例
在线演示
以下示例计算具有边长为 3 和 4 的直角三角形的斜边长度−
<?php $x = 3; $y = 4; echo "hypot(" . $x . "," . $y . ") = " . hypot($x, $y); ?>
Output
This returns largest integer−
hypot(3,4) = 5
Example
Live Demo
Return value of hypot(x,y) function is equal to sqrt(x*x+y*y) as per pythogoras theorem. Following example confirms it−
<?php $x = 3; $y = 4; echo "hypot(" . $x . "," . $y . ") = " . hypot($x, $y) ."</p><p>"; echo "Hypotenuse calculated by Pythogoras equation = " . sqrt(pow($x,2)+pow($y,2)); ?>
输出
这将返回以下输出−
hypot(3,4) = 5 Hypotenuse calculated by Pythogoras equation = 5
Atas ialah kandungan terperinci Fungsi hipot() PHP. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!

Alat AI Hot

Undresser.AI Undress
Apl berkuasa AI untuk mencipta foto bogel yang realistik

AI Clothes Remover
Alat AI dalam talian untuk mengeluarkan pakaian daripada foto.

Undress AI Tool
Gambar buka pakaian secara percuma

Clothoff.io
Penyingkiran pakaian AI

AI Hentai Generator
Menjana ai hentai secara percuma.

Artikel Panas

Alat panas

Notepad++7.3.1
Editor kod yang mudah digunakan dan percuma

SublimeText3 versi Cina
Versi Cina, sangat mudah digunakan

Hantar Studio 13.0.1
Persekitaran pembangunan bersepadu PHP yang berkuasa

Dreamweaver CS6
Alat pembangunan web visual

SublimeText3 versi Mac
Perisian penyuntingan kod peringkat Tuhan (SublimeText3)

Topik panas

