<?php
// PHP Version 5.2.9
$arr = array(75.6, 75.6, -226.8, 75.6);
var_dump(array_sum($arr)); // float(-2.84217094304E-14)
?>
Result is not 0. Why?
Thank you.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This not the problem of
array_sum,echo 75.6+75.6-226.8+75.6;also give you the same result. This is the problem that how computer treats the float number. See here(Floating point) for more information.