当前位置:网站首页>"PHP Basics" use of integer data
"PHP Basics" use of integer data
2022-07-27 08:10:00 【Go home at night】
Functional requirements
Output binary respectively 、 octal 、 Decimal and hexadecimal integers .
The sample code
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title> Output results of different base numbers </title>
</head>
<body>
<?php
$n1 = 123; # Decimal number
$n2 = 0; # zero
$n3 = -123; # negative
$n4 = 0123; # Octal number ( Equal to a decimal number 83)
$n5 = 0x1b; # Hexadecimal number ( Equal to a decimal number 27)
$n6 = 0b1010; # Binary number ( Equal to a decimal number 10)
echo ' Decimal number :'.$n1.'<br>';
echo ' zero :'.$n2.'<br>';
echo ' Negative decimal number :'.$n3.'<br>';
echo ' Octal number :'.$n4.'<br>';
echo ' Hexadecimal number :'.$n5.'<br>';
echo ' Binary number :'.$n6.'<br>';
?>
</body>Running results
Knowledge description
Integer data types can only contain integers . Integer numbers can be in decimal 、 Octal and hexadecimal , Optional symbols can be added to the front (- or +).
Binary expression integer since PHP5.4.0 Available from .
If you want to use octal expression , The number must be preceded by 0( zero ); If you want to use hexadecimal expression , Then the number needs to be preceded by 0x; To use binary representation , The number must be called before 0b.
Be careful : If there are non digits in octal (8 and 9), There is a mistake
Be careful : If the given value exceeds int The maximum range that type can represent , Will be treated as float Type treatment , This situation is called integer overflow . Again , If the final result of the expression exceeds int The range of the type , And will return to float type .
边栏推荐
- How does slf4j configure logback?
- Modification case of Ruixin micro rk3399-i2c4 mounting EEPROM
- C语言:随机生成数+插入排序
- C language: optimized Hill sort
- Sword finger offer 58 - I. flip word order
- Demo:pa30 Bank Country Code default CN enhancement
- C语言:随机生成数+希尔排序
- 2022-07-26 group 4 abstract classes and interfaces
- 增强:BTE流程简介
- Harbor正确密码登录不上去
猜你喜欢

Demo submit a program and obtain ALV data of the program

Prevent cookies from modifying ID to cheat login

Combined use of C WinForm form form event and delegate

"Intermediate and advanced test questions": what is the implementation principle of mvcc?

ERP生产作业控制 华夏

虚拟机克隆

What is the real HTAP? (1) Background article

"PHP Basics" PHP statements and statement blocks

如何在 60 秒内去分析和定位问题?

Use of string type "PHP Basics"
随机推荐
浅谈数据安全
Qt Creator代码风格插件Beautifier
[applet] the upload of the wechat applet issued by uniapp failed error: error: {'errcode': -10008,'errmsg':'Invalid IP
"PHP Basics" uses echo statements to output information
Plato farm is expected to further expand its ecosystem through elephant swap
如何更新pip3?和Running pip as the ‘root‘ user can result in broken permissions and conflicting behaviour
The code interface is a little automated
Methods of server network testing
Shell script learning day01
Hu related configuration
代码接口自动化的有点
Digital transformation driven by enterprise architecture!
C commissioned use cases
Stored procedures and functions
Stored procedure trial 2 -- establish a test table to test different types of stored procedures
shell脚本学习day01
idea远程调试
关于数据库的接口响应非常慢
An ordinary autumn recruitment experience
Day111. Shangyitong: integrate nuxt framework, front page data, hospital details page