php5将64位整数转换为双精度-如何强制64位? [英] php5 converts 64 bit integer to double - how force 64-bit?

查看:154
本文介绍了php5将64位整数转换为双精度-如何强制64位?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在php5中,通过GET传递一个64位整数1707541557936130,但它显示的值为1.7075415579361E+15

in php5, pass a 64bit integer, 1707541557936130 through GET, but it shows value of 1.7075415579361E+15

如何强制php使用大整数作为整数,而不是浮点数

how can I force php to use large integers as integers, not as float

当我移动<<时,其结果显然也是int32,而不是int64

when I shift << apparently the result of that is int32 as well, not int64

是否有一种方法可以全局说使用int64?

is there a way to globally say use int64?

推荐答案

PHP仅在64位系统上支持64位整数.在这两种情况下,大于PHP_INT_MAX的整数都将转换为浮点数. 参见手册.

PHP supports 64bit integers only on 64bit systems. In both cases integers, that are larger than PHP_INT_MAX, are converted to floats. see manual.

尝试以下代码:

<?php
$i=1707541557936130;
var_dump($i);    
echo PHP_INT_MAX;

这篇关于php5将64位整数转换为双精度-如何强制64位?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆