Home >Backend Development >PHP Tutorial >神奇的PHP 让我找不着北 floatval转 intval 变小

神奇的PHP 让我找不着北 floatval转 intval 变小

WBOY
WBOYOriginal
2016-06-23 13:58:20938browse

//无解了 想不通,求解$c=2700*0.7;$m=1890;var_dump($c<$m); // 两个者的值都是1890 但它却返回 trueecho intval($c);// c应该是1890的 但经过intval 它变成了 1889


回复讨论(解决方案)

$c = 2700*0.7;printf('%.14f', $c); //1889.99999999999977

$c的值本来就小于$m,不返回true返回什么?

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