当前位置:网站首页>"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 .
边栏推荐
猜你喜欢

【机器人学习】机械臂抓手matlab运动学与admas动力学分析

Shell programming specifications and variables

12_ UE4 advanced_ Change a more beautiful character model

Chapter 09_ Use of performance analysis tools

2. Nodejs -- path (\dirname, \filname), URL URL, querystring module, mime module, various paths (relative paths), web page loading (interview questions *)
![[open the door to the new world] see how the old bird of testing plays API testing between applause](/img/79/1bc836cefef24d23e09d9865ff1fba.png)
[open the door to the new world] see how the old bird of testing plays API testing between applause

What is SOA (Service Oriented Architecture)?

【打开新世界大门】看测试老鸟如何把API 测试玩弄在鼓掌之间

「PHP基础知识」输出圆周率的近似值

HTB-Blocky
随机推荐
Restfulapi - C - add header username and password authentication
2.nodejs--路径(_dirname,_filname)、url网址、querystring模块、mime模块、各种路径(相对路径)、网页的加载(面试题*)
Tp5.0 applet users do not need to log in and directly obtain the user's mobile number.
Idea replaces the contents of all files
Pytest environment deployment + use case execution management + use case parameterization
Why did I choose the test when the development salary was high?
Notes on the ninth day
【C】数组
C陷阱与缺陷 第3章 语义“陷阱” 3.4 避免“举偶法”
Apache文件管理自学笔记——映射文件夹和基于单ip多域名配置apache虚拟机
三子棋(玩家+电脑)
Interpreting AI robots' pet raising and leading fashion trends
第09章_性能分析工具的使用
Pgzero飞机大战
C陷阱与缺陷 第3章 语义“陷阱” 3.7 求值顺序
明明开发薪资高,为什么我还是选了测试?
The basic concept of the origin and connotation of maker Education
百度副总裁李硕:数字技术加持下中国劳动力成本上升是好事
TP5.0 小程序用户无需登录,直接获取用户手机号。
shell脚本总结