raphael75 Posted May 1, 2014 Share Posted May 1, 2014 (edited) So I have 2 arrays of numbers, and this:$variance = array_sum($db_tot) - array_sum($cr_tot);If the sum of each array is the same, why does PHP return -1.8189894035459E-12? Why wouldn't it be 0 (positive 0 or just 0)?Thanks! Edited May 1, 2014 by raphael75 Quote Link to comment Share on other sites More sharing options...
Solution raphael75 Posted May 1, 2014 Author Solution Share Posted May 1, 2014 Figured it out - floating point math isn't straightforward. Had to use number_format to round to 2 decimal places. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.