当前位置:网站首页>"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 .
边栏推荐
- MySQL - count(字段)、count(主键)、count(1)、count(*)的区别
- 增量实时灾备笔记
- 带你来浅聊一下,单商户功能模块汇总
- 算法---粉刷房子(Kotlin)
- 万字详解 Google Play 上架应用标准包格式 AAB
- C#从网址异步获得json格式的数据
- Available data sets for scene classification tasks (part)
- MySQL operation database data error: fatal error encoded during command execution
- C语言基础知识点汇总
- Pytest environment deployment + use case execution management + use case parameterization
猜你喜欢

R language error: compilation failed for package '****‘

【FreeSwitch开发实践】UniMRCP编译与安装

Redis configuration cache expiration listening event trigger

金山云回港上市:中国TO B云厂商的港股奔袭

Mongodb index (3)

Analysis of Project-based Learning Creativity in steam Education

What is SOA (Service Oriented Architecture)?

2.nodejs--路径(_dirname,_filname)、url网址、querystring模块、mime模块、各种路径(相对路径)、网页的加载(面试题*)

Inventory of domestic and foreign project collaborative management software: SAAS and customization become a trend

【机器人学习】机械臂抓手matlab运动学与admas动力学分析
随机推荐
[Luogu p8352] independent set of small n (DP set DP) (property)
C陷阱与缺陷 第3章 语义“陷阱” 3.7 求值顺序
C language small project - address book (static version + dynamic version + file version)
解析Steam教育中的项目式学习创造力
【FreeSwitch开发实践】UniMRCP编译与安装
OSPF experiment
Summary of common hooks
Shell programming specifications and variables
VASP calculation task error: M_ divide:can not subdivide 8 nodes by 6
C陷阱与缺陷 第2章 语法“陷阱” 2.6 “悬挂”else引发的问题
Idea replaces the contents of all files
C陷阱与缺陷 第3章 语义“陷阱” 3.6 边界计算与不对称边界
Redis配置缓存过期监听事件触发
Apache文件管理自学笔记——映射文件夹和基于单ip多域名配置apache虚拟机
MYSQL入门与进阶(十二)
Li Shuo, vice president of Baidu: it's a good thing that China's labor costs rise with the support of digital technology
C traps and defects Chapter 3 semantic "traps" 3.2 pointers to non arrays
第2章 VRP命令行
cuda-gdb提示:/tmp/tmpxft_***.cudafe1.stub.c: No such file or directory.
MySQL忘记密码怎么办