Home  >  Article  >  Backend Development  >  浮点型在内存中的怎么存储的。

浮点型在内存中的怎么存储的。

WBOY
WBOYOriginal
2016-06-06 20:34:44969browse

<code>echo number_format(19.99 * 100, 20);    // output:1,998.99999999999977262632
</code>

为什么会这样?浮点型是怎么存储的。我的想法可能是浮点型本来就不是精确存储的。
解决了这个问题也就知道为什么intval后的值是1998了。

回复内容:

<code>echo number_format(19.99 * 100, 20);    // output:1,998.99999999999977262632
</code>

为什么会这样?浮点型是怎么存储的。我的想法可能是浮点型本来就不是精确存储的。
解决了这个问题也就知道为什么intval后的值是1998了。

浮点数的存储精度跟系统有关,PHP 通常使用 IEEE 754 双精度格式,默认是20位有效精度。Floating point numbers

浮点数使用指南

贴上中文的浮点型 http://php.net/manual/zh/language.types.float.php

Statement:
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