PHP中把有符号整型转换为无符号整型方法,php整型_PHP教程

WBOY
Release: 2016-07-13 09:52:18
Original
1560 people have browsed it

PHP中把有符号整型转换为无符号整型方法,php整型

在一个短地址项目中,根据六位字符与ID的相互映射的算法,当ID超过2147483647的时候,六位字符的短地址映射的ID变成有符号的整型。

复制代码 代码如下:
ID        >     六位字符    >映射ID   

ID: 2147483644 > TfffVQ > 2147483644
ID: 2147483645 > efffVQ > 2147483645
ID: 2147483646 > NfffVQ > 2147483646
ID: 2147483647 > ffffVQ > 2147483647
ID: 2147483648 > nnnnnu > -2147483648
ID: 2147483649 > dnnnnu > -2147483647
ID: 2147483650 > rnnnnu > -2147483646

需要把有符号整型转换为无符号整型:(float) sprintf('%u', $id)

PHP官网关于整型的资料:http://php.net/manual/zh/language.types.integer.php

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1008024.htmlTechArticlePHP中把有符号整型转换为无符号整型方法,php整型 在一个短地址项目中,根据六位字符与ID的相互映射的算法,当ID超过2147483647的时候,六...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!