PHP对于无符号数,数据较大时,格式化会出现差1或2的情况,替代办法用mysql来计算结果
实例代码如下:
private function getUnsinInt($number)
{
$sql = "SELECT
CAST(
($number & 0xFFFFFFFF) AS UNSIGNED INTEGER
) as uns_int;";
$res = pdo_fetch($sql);
return $res[‘uns_int‘];
}
2022-10-05 21:33:46
PHP对于无符号数,数据较大时,格式化会出现差1或2的情况,替代办法用mysql来计算结果
实例代码如下:
private function getUnsinInt($number)
{
$sql = "SELECT
CAST(
($number & 0xFFFFFFFF) AS UNSIGNED INTEGER
) as uns_int;";
$res = pdo_fetch($sql);
return $res[‘uns_int‘];
}
下一篇:前端基础JS篇之面向对象