php 将浮点转换为长整型(转换为字符串以传递给 xml 函数)

发布于 2024-09-12 07:21:57 字数 250 浏览 3 评论 0原文

PHP 将大量数字转换为浮点数,我需要将其以“长”格式传递给soap xml api。

((round(time()/(60*15))*60*15)+(30*60))*1000

这给出了结果:

1.28E+12

然而,我需要的是:

"1280495700000"

为了传递给 api

PHP converts a large number to floating point which I need in "long" format to pass to a soap xml api.

((round(time()/(60*15))*60*15)+(30*60))*1000

This gives the result:

1.28E+12

Whereas, what I need is:

"1280495700000"

in order to pass to the api

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦途 2024-09-19 07:21:57

使用 number_format() 对其进行格式化

http://php.net/manual/en/ function.number-format.php

雨轻弹 2024-09-19 07:21:57

这可能有效:

sprintf('%u',$number);

但如果您即将失去所需的精度,请查看 BCMath 函数(bcaddbcdiv 等)。他们会保持精确度,并给你返回字符串。

This could work:

sprintf('%u',$number);

But if you're about to lose precision you need, look at the BCMath functions (bcadd, bcdiv and the like). They will keep precision, and give you back strings.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文