一、整数的表示方法:

整型值可以使用十进制十六进制八进制二进制表示,前面可以加上可选的符号(- 或者 +

要使用二进制表达,数字前必须加上 0b

要使用八进制表达,数字前必须加上 0

要使用十六进制表达,数字前必须加上 0x

     echo 1234;      // 十进制数
echo -123; // 负数
echo 0123; // 八进制数 (等于十进制 83)
echo 0x1A; // 十六进制数 (等于十进制 26)
echo 0b0101; // 二进制数(等于十进制 5)

二、整数的范围:

32位操作系统:正负(2^31)-1;

64位操作系统:正负(2^63)-1;

integer 的最小和最大值可用 PHP_INT_MIN  和  PHP_INT_MAX 表示

integer 的字长可用 PHP_INT_SIZE 表示

三、整数的转换

要明确地将一个值转换为 integer,用 (int) 、 (integer) intval()  强制转换

1、布尔值转换: false => 0;    true => 1;

2、浮点数转换:向下取整

      var_dump(intval(false));    //
var_dump(intval(true)); //
var_dump(intval(3.9)); //

注:

1、如果向八进制数传递了一个非法数字(即 8 或 9),则后面其余数字会被忽略

var_dump(01090); // 八进制 010 = 十进制 8

2、如果给定的一个数超出了 integer 的范围,将会被解释为 float。同样如果执行的运算结果超出了 integer 范围,也会返回 float

var_dump(pow(2,64));       //  float 1.844674407371E+19

php integer的更多相关文章

  1. LeetCode 7. Reverse Integer

    Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 Have you ...

  2. Integer.parseInt 引发的血案

    Integer.parseInt 处理一个空字符串, 结果出错了, 程序没有注意到,搞了很久, 引发了血案啊!! 最后,终于 观察到了, 最后的部分: Caused by: java.lang.NoC ...

  3. 由一个多线程共享Integer类变量问题引起的。。。

    最近看到一个多线程面试题,有三个线程分别打印A.B.C,请用多线程编程实现,在屏幕上循环打印10次ABCABC- 看到这个题目,首先想到的是解决方法是定义一个Integer类对象,初始化为0,由3个线 ...

  4. [LeetCode] Integer Replacement 整数替换

    Given a positive integer n and you can do operations as follow: If n is even, replace n with n/2. If ...

  5. [LeetCode] Integer Break 整数拆分

    Given a positive integer n, break it into the sum of at least two positive integers and maximize the ...

  6. [LeetCode] Integer to English Words 整数转为英文单词

    Convert a non-negative integer to its english words representation. Given input is guaranteed to be ...

  7. [LeetCode] Roman to Integer 罗马数字转化成整数

    Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 t ...

  8. [LeetCode] Integer to Roman 整数转化成罗马数字

    Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 t ...

  9. [LeetCode] String to Integer (atoi) 字符串转为整数

    Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. ...

  10. [LeetCode] Reverse Integer 翻转整数

    Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 click to ...

随机推荐

  1. Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again

    # yum install -y vim Loaded plugins: fastestmirror, presto Loading mirror speeds from cached hostfil ...

  2. convertToNodeSpace和convertToWorldSpace ---实际应用

    游戏中经常会用到一些变换: 游戏中武器和角色在一个layer上,为了效率,会考虑将bullet, effect和 PhysicsParticle分别放到不用的层上,对应的层上使用batchnode来提 ...

  3. S5PV210初始化系统时钟

    S5PV210初始化系统时钟 S5PV210时钟体系S5PV210中包含3大类时钟domain,分别是主系统时钟domain (简称MSYS,下面将使用简称来进行相关讲解).显示相关的时钟domain ...

  4. centos7 Firewalld操作集合

    =============================================== 2019/4/15_第1次修改                       ccb_warlock == ...

  5. 关于报错stale element reference: element is not attached to the page document处理

    1.现象 在执行脚本时,有时候引用一些元素对象会抛出如下异常 org.openqa.selenium.StaleElementReferenceException: stale element ref ...

  6. PYTHON-模块-time&datetime-练习 +目录规范

    # 作业# 1.请写出规范目录# 并解释各文件夹的作用bin 可执行文件conf 配置文件core 主要业务逻辑db 数据文件lib 库(公共代码 第三方模块)log 日志文件 # 2.改造atm + ...

  7. LeetCode(45): 跳跃游戏 II

    Hard! 题目描述: 给定一个非负整数数组,你最初位于数组的第一个位置. 数组中的每个元素代表你在该位置可以跳跃的最大长度. 你的目标是使用最少的跳跃次数到达数组的最后一个位置. 示例: 输入: [ ...

  8. cf803c 数论

    细节很多的题 #include<bits/stdc++.h> using namespace std; #define ll long long int main(){ ll n,k,tm ...

  9. Slave SQL_THREAD如何重放Relay log

    复制的介绍: 根据日志定义的模式不一样,可以分为:Statement(SBR)模式,Row(RBR)格式或者是MIXED格式,记录最小的单位是一个Event,binlog日志前4个字节是一个magic ...

  10. 步步为营-57-JQuery练习题

    01 点谁谁哭 <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head&g ...