当前位置:网站首页>"PHP Basics" output approximate value of PI
"PHP Basics" output approximate value of PI
2022-07-29 03:05:00 【Go home at night】
Functional requirements
The representation of floating-point numbers , Use four methods to output PI (π=3.1415926) Approximate value :① Use pi() function ;② Use M_PI Constant ;③ Use standard format ;④ Use scientific counting .
The sample code
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title> Output the approximate value of PI </title>
</head>
<body>
<?php
echo ' PI 4 Writing methods :<p>';
echo ' The first one is :pi() = '. pi() .'<br />'; # Use pi() function
echo ' The second kind :M_PI = '.M_PI.'<br />'; # Use a constant M_PI
echo ' The third kind of :3.14159265359 = '. 3.14159265359 .'<br />'; # A standard format
echo ' A fourth :314159265359E-11 = '. 314159265359E-11 .'<br />'; # Scientific enumeration
?>
</body>Running results
Knowledge description
Floating point data types are also known as floating point numbers 、 A double or real number , It can be used to store numbers , You can also save decimals . It provides much greater precision than integers . Floating point data has two writing formats by default :
One is standard format :
3.1415
-35.8
One is the format of scientific counting :
3.58E1
849.72E-3
Be careful : Floating point numbers are only an approximation , So try to avoid comparing sizes between floating-point numbers , Because the final result is inaccurate .
pi(): It's a function , Return the PI PI Approximate value .
M_PI: Is a constant , Show pi PI Approximate value .
边栏推荐
猜你喜欢

Engineering boy: under 20 years old, ordinary but not mediocre

Unity 之游戏特效

Analysis of concepts and terms in data warehouse

会议OA之反馈功能

2022-07-28 顾宇佳 学习笔记

Jinshan cloud returns to Hong Kong for listing: Hong Kong stock rush of Chinese to B cloud manufacturers

13_ue4进阶_蒙太奇动画实现一边走一边攻击

第2章 VRP命令行

Hangao database best practice configuration tool Hg_ BP log collection content

Notes on the sixth day
随机推荐
向DataFrame中的特定位置添加一行
centos安装mysql8
三子棋(玩家+电脑)
01-sdram: Code of initialization module
vasp计算任务报错:M_divide:can not subdivide 8 nodes by 6
Summary of common hooks
Unable to start after idea installation
Groupby method
2022-07-28 第四小组 修身课 学习笔记(every day)
C语言小项目 -- 通讯录(静态版+动态版+文件版)
Plato Farm在Elephant Swap上铸造的ePLATO是什么?为何具备高溢价?
Look at robot education and lead the mainstream of quality education
Summary of classic problems in Flink production environment
《QA离业务代码能有多近?》QA对业务代码进行可测性改造
Redis配置缓存过期监听事件触发
R language error: compilation failed for package '****‘
The origin of Nacos' name
C陷阱与缺陷 第3章 语义“陷阱” 3.3 作为参数的数组声明
HTB-Blue
Why did I choose the test when the development salary was high?