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

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

WBOY
Release: 2016-06-23 13:58:20
Original
933 people have browsed it

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


回复讨论(解决方案)

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

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template